beh*_*aqi 2 android textview android-scrollview
我是android的初学者,我编写简单的apllication在android studio中的textView中显示一个简单的文本,但是当我在textView中写一个大文本时,textview无法滚动,我的xml文件是:
<android.support.v4.widget.DrawerLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools" android:id="@+id/drawer_layout"
android:layout_width="match_parent" android:layout_height="match_parent"
tools:context=".MainActivity">
<FrameLayout android:id="@+id/container" android:layout_width="match_parent"
android:layout_height="match_parent" >
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textAppearance="?android:attr/textAppearanceLarge"
android:text="Large Text"
android:id="@+id/MAINLABEL"
android:layout_gravity="center" />
</FrameLayout>
</android.support.v4.widget.DrawerLayout>
Run Code Online (Sandbox Code Playgroud)
发生什么事?
<HorizontalScrollView android:layout_width="fill_parent"
android:layout_height="fill_parent">
<TextView android:layout_width="40dp"
android:layout_height="wrap_content"
android:scrollHorizontally="true"
android:text="Horizontal scroll view will work now"/>
</HorizontalScrollView>
Run Code Online (Sandbox Code Playgroud)
你不需要ScrollView实际使用.
只需设置
android:maxLines = "AN_INTEGER"
android:scrollbars = "vertical"
Run Code Online (Sandbox Code Playgroud)
TextView布局的xml文件中的属性.
然后使用:
yourTextView.setMovementMethod(new ScrollingMovementMethod());
在你的代码中.
它会帮助你.谢谢.
| 归档时间: |
|
| 查看次数: |
2751 次 |
| 最近记录: |