Android --固定底部

时间:2023-03-09 03:18:45
Android --固定底部

相对布局:

<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.dr.app.drseamoniter.HistoryDataFragment">

    <ListView
        android:id="@+id/history_data_list"
        android:layout_width="fill_parent"
        android:layout_height="wrap_content"
        android:layout_above="@+id/history_data_bottom"/>

    <LinearLayout
        android:id="@+id/history_data_bottom"
        android:orientation="horizontal"
        android:layout_width="fill_parent"
        android:layout_height="wrap_content"
        android:gravity="center"
        android:layout_alignParentBottom="true">

        <ImageView
            android:id="@+id/page_back"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_weight="1"
            android:gravity="center"
            android:src="@drawable/page_back"/>
        <EditText
            android:id="@+id/page"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:gravity="center"
            android:textSize="12sp"
            android:layout_weight="1"/>
        <ImageView
            android:id="@+id/page_forward"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:gravity="center"
            android:layout_weight="1"
            android:src="@drawable/page_forward"/>
        <TextView
            android:id="@+id/total_page_count"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:text="@string/data_list_page_count"
            android:gravity="center"
            android:textSize="12sp"
            android:layout_weight="1"/>
        <TextView
            android:id="@+id/total_count"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:text="@string/data_list_count"
            android:gravity="center"
            android:textSize="12sp"
            android:layout_weight="1"/>
    </LinearLayout>

</RelativeLayout >

参考博客:Android常见错误

在相对布局中,若是用到android:layout_above属性,并且其后id之前没有出现过,那么需要这样写:android:layout_above="@+id/vidAdd_ButtonGroup",多加一个“+”。