底部带有固定按钮的Android布局

时间:2018-09-02 14:24:34

标签: android xml

我有以下xml,应该类似于the following

该活动大部分显示正常,但我无法使两个向下按钮固定在屏幕底部而不会弄乱顶视图。

我尝试将FrameLayout与两个RelativeLayouts一起使用,alignment_bottom,组件之间的权重为1的空视图,甚至还不能实现我的目标。任何帮助将不胜感激,谢谢您。

<?xml version="1.0" encoding="utf-8"?>

<LinearLayout android:layout_width="match_parent"
android:orientation="vertical"
android:layout_height="match_parent"
xmlns:android="http://schemas.android.com/apk/res/android">

<ScrollView android:layout_width="match_parent" android:layout_height="match_parent"
    xmlns:android="http://schemas.android.com/apk/res/android">

<RelativeLayout
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    android:id="@+id/RelativeLayout1">

    <ImageView
        android:id="@+id/group_info_image"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:scaleType="fitStart"
        android:adjustViewBounds="true"
        android:layout_alignParentTop="true"
        />

    <TextView
        android:id="@+id/description_text"
        android:layout_below="@id/group_info_image"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:textColor="@color/mainColor"
        android:textSize="20sp"
        android:text="@string/descripcion"
        android:layout_marginStart="10dp"
        android:layout_marginTop="10dp"
        android:fontFamily="sans-serif"
        />

    <TextView
        android:layout_below="@id/description_text"
        android:gravity="start"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:id="@+id/group_info_description"
        android:layout_marginTop="5dp"
        android:layout_marginBottom="10dp"
        android:layout_marginStart="10dp"

        android:textSize="15sp"/>

    <TextView
        android:layout_below="@id/group_info_description"
        android:scrollbars="vertical"
        android:gravity="center"
        android:textColor="@android:color/black"
        android:layout_marginTop="10dp"
        android:layout_marginStart="5dp"
        android:layout_marginBottom="2dp"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:id="@+id/group_info_user_number"
        android:textSize="15sp"
        />

    <es.tretornesp.clickerchat.NonScrollableListView
        android:layout_below="@id/group_info_user_number"
        android:id="@+id/group_info_user_list"
        android:layout_height="match_parent"
        android:divider="@drawable/list_divider"
        android:dividerHeight="1px"
        android:layout_width="match_parent"/>

</RelativeLayout>
</ScrollView>

<LinearLayout
    android:orientation="vertical"
    android:layout_width="match_parent"
    android:layout_height="wrap_content">

    <Button
        android:id="@+id/delete_group"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:text="@string/borrar_grupo"
        android:background="@color/mainColor" />

    <View
        android:id="@+id/divisor"
        android:layout_width="match_parent"
        android:layout_height="1dp"
        android:background="@color/grey"/>


    <Button
        android:id="@+id/exit_group"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:textColor="@android:color/white"
        android:text="@string/salir"
        android:background="@color/mainColor"
        />
</LinearLayout>
</LinearLayout>

2 个答案:

答案 0 :(得分:1)

如下更改布局文件,

<link rel="shortcut icon" href="favicon.ico">

答案 1 :(得分:0)

Use Coordinator Layout as a parent layout. like this.

<android.support.design.widget.CoordinatorLayout xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:app="http://schemas.android.com/apk/res-auto"
    xmlns:card_view="http://schemas.android.com/tools"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:fitsSystemWindows="false">


// your code 

   <LinearLayout
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:layout_gravity="bottom"
        android:orientation="horizontal">

        <TextView
            android:id="@+id/txt_contact_laksha_group"
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
           android:text="demo"
        />

    </LinearLayout>

</android.support.design.widget.CoordinatorLayout>