[英]how to make scrollable horizontally and vertically the contents of a TextView
我想滾動在TextView中查看的結果,這是我的xml:
<scroll>
<TextView
android:id="@+id/ris"
android:layout_width="wrap_content"
android:layout_height="229dp"
android:layout_weight="0.96"
android:textAppearance="?android:attr/textAppearanceMedium" />
</scroll>
但該應用程序崩潰了。
采用
<ScrollView> your View "</ScrollView">
並且必須只有一個子ScrollView。
在TextView的XML文件中添加
android:scrollHorizontally="true"
android:scrollVertically="true"
將以下內容添加為TextView
屬性:
android:maxLines = "1"
android:scrollbars = "vertical"
然后,實例化TextView
,添加以下行:
mTextView.setMovementMethod(new ScrollingMovementMethod());
<ScrollView
android:id="@+id/scrollView1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginRight="19dp"
android:layout_marginTop="24dp" >
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content" >
<TextView
android:id="@+id/tv"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="@string/hello_world"
tools:context=".Tester" />
</LinearLayout>
</ScrollView>
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.