【发布时间】:2018-09-02 14:24:33
【问题描述】:
我有以下 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>
【问题讨论】:
-
您用模拟器在哪些设备上试过这个?
-
将按钮放在滚动视图之外,否则它也会滚动..
-
@Kwright02 我的笔记本电脑无法运行模拟器,我通过 adb 在 bq aquaris m5 (api 25) 和 samsung note 8 上进行测试
-
@MohamedMohaideenAH 已编辑,改进不错,但还是有同样的问题
-
你想要什么?你想删除和退出组按钮与底部对齐还是整个线性布局与底部对齐?