我的xml中有一个小问题。我无法滚动Textview
<RelativeLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentStart="true"
android:layout_below="@+id/nameTxtdetails">
<ScrollView
xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="wrap_content"
android:layout_height="wrap_content">
<TextView
android:id="@+id/descDetailTxt"
android:layout_width="match_parent"
android:layout_height="200dp"
android:layout_alignParentStart="true"
android:background="@drawable/gradient"
android:maxLines="5"
android:padding="15dp"
android:text="the most aksfjklasjfsdklfnafmafafsasfasfasjaskasdjklasdjklasdjklasdjklasdjkasdjklasdjklasdjklasdjklasdjklasdjklasdjklasdjklasdjsdgsdfsdfsdfsdfsdfsdfsdfsdfsdfsdfsdfsdfsdfsdfsdfsdfsdfsdfdfsfsdfklasdjklasdjklasdjklasdjklasdjklasdjklasdjklasdjklsdjklasdjkadjadaskdkddmljlsdfjksdjfksdlfjsdlkfjsdklfjskldfjklsdflsdjfsdlfjsdlfklsdfjlsdfjsdflma"
android:textAppearance="?android:attr/textAppearanceLarge"
android:textColor="#FFFF"
android:textStyle="bold" /> </ScrollView>
</RelativeLayout>
</RelativeLayout>
<TextView
android:id="@+id/descDetailTxt"
android:layout_width="match_parent"
android:layout_height="200dp"
android:layout_alignParentStart="true"
android:background="@drawable/gradient"
android:maxLines="5"
android:padding="15dp"
android:scrollbars="vertical"
android:text="the most aksfjklasjfsdklfnafmafafsasfasfasjaskasdjklasdjklasdjklasdjklasdjkasdjklasdjklasdjklasdjklasdjklasdjklasdjklasdjklasdjsdgsdfsdfsdfsdfsdfsdfsdfsdfsdfsdfsdfsdfsdfsdfsdfsdfsdfsdfdfsfsdfklasdjklasdjklasdjklasdjklasdjklasdjklasdjklasdjklsdjklasdjkadjadaskdkddmljlsdfjksdjfksdlfjsdlkfjsdklfjskldfjklsdflsdjfsdlfjsdlfklsdfjlsdfjsdflma"
android:textAppearance="?android:attr/textAppearanceLarge"
android:textColor="#FFFF"
android:textStyle="bold" />
public class Main2Activity extends AppCompatActivity {
TextView tv;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main2);
tv = (TextView) findViewById(R.id.descDetailTxt);
tv.setMovementMethod(new ScrollingMovementMethod());
}}
所以任何人都可以告诉我一种我可以滚动textview的方法,因为我已经尝试了很多方法,但是它甚至都没有用。谢谢