我无法滚动我的文本视图

时间:2018-07-16 17:17:45

标签: textview scrollview

我的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" />

这是Java文件

   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的方法,因为我已经尝试了很多方法,但是它甚至都没有用。谢谢

0 个答案:

没有答案