讓TextView 有滾動條的效果

網上搜了好幾頁都不夠詳細,最直接的方法就是在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>



發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章