按钮在界面最下面

来源:互联网 发布:淘宝现货怎么抢最快 编辑:程序博客网 时间:2024/06/05 23:01

主要用到了Scrollview的fillViewport的属性。

android:fillViewport="true"

举个例子:

<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"

    xmlns:tools="http://schemas.android.com/tools"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    tools:context="com.example.shipingtest2.MainActivity" >
    <ScrollView
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:fillViewport="true" >
        <LinearLayout
            android:layout_width="match_parent"
            android:layout_height="match_parent"
            android:orientation="vertical" >
            <LinearLayout
                android:layout_width="match_parent"
                android:layout_height="0dp"
                android:layout_weight="1"
                android:orientation="vertical" >
                <TextView
                    android:layout_width="wrap_content"
                    android:layout_height="wrap_content"
                    android:layout_gravity="center"
                    android:text="测试的文字"
                    android:textSize="100dp" />
            </LinearLayout>
            <LinearLayout
                android:layout_width="match_parent"
                android:layout_height="wrap_content"
                android:layout_marginBottom="20dp"
                android:gravity="center_horizontal" >

                <Button
                    android:layout_width="wrap_content"
                    android:layout_height="wrap_content"
                    android:text="确定" />
            </LinearLayout>
        </LinearLayout>
    </ScrollView>
</RelativeLayout>
0 0
原创粉丝点击