1
我有一個問題,但我沒有在我的搜索中得到任何答案。如何使2 TextViews可滾動而不使佈局可滾動?
我正在使用1 EditText
和2 TextView
,如果TextView
的容量增加,它不會增加它,我無法使其滾動。
我需要爲它們添加無限文本。
我需要兩個文本視圖作爲可滾動。
請幫我找到解決方案。
我曾嘗試:
android:maxLines = "AN_INTEGER"
android:scrollbars = "vertical"
yourTextView.setMovementMethod(new ScrollingMovementMethod());
and
<LinearLayout
android:orientation="vertical"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:layout_below="@+id/linear1">
<ScrollView
android:id="@+id/SCROLLER_ID"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:scrollbars="vertical"
android:fillViewport="true">
<TextView
android:id="@+id/TEXT_STATUS_ID"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:scrollbars="vertical"
android:layout_weight="1.0"/>
</ScrollView>
</LinearLayout>
mTextStatus = (TextView) findViewById(R.id.TEXT_STATUS_ID);
mScrollView = (ScrollView) findViewById(R.id.SCROLLER_ID);
private void scrollToBottom()
{
mScrollView.post(new Runnable()
{
public void run()
{
mScrollView.smoothScrollTo(0, mTextStatus.getBottom());
}
});
}
而且我想通過如果有更多的文字意味着它應該是滾動的,不知道該文本的長度只有3條線路,後來顯示TextView
文本。
請幫我找到解決方案。
你肯定您r回答我需要顯示我的文本只行如果任何文本添加它也應該顯示3行時,更多的文本添加意味着它應該可滾動..! @BrunoFerreira –
如果你不添加文本,它不會做任何事情,因爲textview沒有比屏幕大小更多的文本,如果你有更多的文本比屏幕大小的文本視圖變得可滾動。你可以嘗試我的代碼,如果你做得很好,如果不是隻發送一個回覆知道! @AjayJain –
如果我明白你只想顯示3行,並使滾動,如果文本超過屏幕大小 –