让TextView 有滚动条的效果

来源:互联网 发布:七天精通js 编辑:程序博客网 时间:2024/05/17 04:42
网上搜了好几页都不够详细,最直接的方法就是在ScrollView 里面嵌套上TextView,关键属性设置是:
android:fadeScrollbars="true" 滚动条自动隐藏和显示,隐藏还是显示取决于内容的多少;
android:scrollbars="vertical" >  滚动条垂直方向
还有一个就是用相对布局,把TextView 定位到顶部,把菜单按钮固定在底部,如果把

TextView 替换成其他内容就是一个现在流行的界面了,比如,膜拜的地图,淘宝的列表等待




<?xml version="1.0" encoding="utf-8"?><RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"    xmlns:tools="http://schemas.android.com/tools"    android:id="@+id/RelativeLayout1"    android:layout_width="match_parent"    android:layout_height="match_parent" >    <ScrollView        android:layout_width="fill_parent"        android:layout_height="match_parent"        android:fadeScrollbars="true"        android:scrollbars="vertical" >            <TextView            android:id="@+id/textView"            android:layout_width="wrap_content"            android:layout_height="wrap_content"            android:layout_alignParentTop="true"            android:padding="30px"            android:textColor="#000000"            android:textSize="40px"/>    </ScrollView>             <Button            android:layout_width="wrap_content"            android:layout_height="wrap_content"            android:layout_alignParentBottom="true"            android:layout_centerHorizontal="true"            android:radius="5dip"            android:background="#ccc"            android:focusable="false"            android:text="开始" />    </RelativeLayout>



原创粉丝点击