我在我的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