我在我的LinearLayout
中設置了ScrollView
。我想要一個TextView
滾動。我試圖在xml中使用ScrollView
。但是,它不工作。android textview scrollview在佈局滾動視圖
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical"
android:padding="8dp"
tools:context=".SubpagesLayout.ReportResult">
<!-- first scrollView -->
<ScrollView
android:layout_width="match_parent"
android:layout_height="match_parent">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical">
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="@drawable/edit_corner_blue"
android:gravity="center"
android:text="@string/personalInformation"
android:textColor="@android:color/white" />
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="8dp"
android:orientation="horizontal">
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="@string/birthDate" />
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text=" TestData" />
</LinearLayout>
<!-- second scrollView -->
<ScrollView
android:layout_width="match_parent"
android:layout_height="wrap_content">
<TextView
android:id="@+id/textOphthalmoscopy"
android:layout_width="match_parent"
android:layout_height="80dp"
android:text="standard instrth various settings that allow focusing and adjustment of the light source to accommodate the viewer and to evaluate various features of the fundus." />
</ScrollView>
</LinearLayout>
</ScrollView>
</LinearLayout>
我想這樣的一種方式,但它仍然沒有工作過。
android:maxLines = "AN_INTEGER"
android:scrollbars = "vertical"
我用
myTextView.setMovementMethod(new ScrollingMovementMethod());
因此,如何讓TextView
滾動?如果是第二個ScrollView
。
你不能使用嵌套的滾動視圖,請嘗試使用由Android提供的NestedScrollView,但是避免嵌套滾動如果U可以 – Ak9637
是的,這NestedScrollView!感謝您的幫助,但爲什麼我應該避免NestedScrollView? –
我不知道這個技術的答案,但物理上它不建議在另一個滾動表面有一個滾動,因爲android是基於MATERIAL UI – Ak9637