我想将两个按钮粘贴或附加到导航抽屉的底部。 我没有将按钮连接到底部,这些按钮始终显示在导航抽屉的底部 我尝试了layout_weight,但它反应不佳。 我的代码如下。 我在下图中描述它 请帮助我。提前谢谢
<?xml version="1.0" encoding="utf-8"?>
<android.support.v4.widget.DrawerLayout
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:id="@+id/drawer_layout"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="@color/setting_background" >
<RelativeLayout
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:ads="http://schemas.android.com/apk/lib/com.google.ads"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="@color/exp_background"
android:gravity="top"
android:orientation="vertical" >
<ListView
android:id="@+id/news_list"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_alignParentLeft="true"
android:layout_below="@+id/adView"
android:cacheColorHint="@android:color/transparent"
android:divider="@color/news_list_divider_color"
android:dividerHeight="@dimen/news_list_divider_height" >
</ListView>
</RelativeLayout>
<LinearLayout
android:id="@+id/newlist_relative"
android:layout_width="wrap_content"
android:layout_height="fill_parent"
android:layout_alignParentTop="true"
android:layout_gravity="right"
android:background="@color/setting_background"
android:orientation="vertical" >
<ListView
android:id="@+id/newslist_drawer"
android:layout_width="wrap_content"
android:layout_height="0dip"
android:layout_alignParentTop="true"
android:layout_gravity="right"
android:layout_weight=".95"
android:background="@color/setting_background"
android:cacheColorHint="@android:color/transparent"
android:choiceMode="singleChoice"
android:divider="@android:color/transparent"
android:dividerHeight="0dp" />
<LinearLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="@+id/newslist_drawer"
android:layout_weight=".05" >
<Button
android:id="@+id/newslist_done"
android:layout_width="0dip"
android:layout_height="wrap_content"
android:layout_weight="0.5"
android:text=" Done "
tools:ignore="NestedWeights" />
<Button
android:id="@+id/newslist_cancel"
android:layout_width="0dip"
android:layout_height="wrap_content"
android:layout_weight="0.5"
tools:ignore="NestedWeights"
android:text=" Cancel " />
</LinearLayout>
</LinearLayout>
</android.support.v4.widget.DrawerLayout>
答案 0 :(得分:1)
<RelativeLayout
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:ads="http://schemas.android.com/apk/lib/com.google.ads"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="@color/exp_background"
android:gravity="top"
android:orientation="vertical" >
<ListView
android:id="@+id/news_list"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_alignParentLeft="true"
android:layout_below="@+id/adView"
android:cacheColorHint="@android:color/transparent"
android:divider="@color/news_list_divider_color"
android:dividerHeight="@dimen/news_list_divider_height" >
</ListView>
</RelativeLayout>
<LinearLayout
android:id="@+id/newlist_relative"
android:layout_width="wrap_content"
android:layout_height="fill_parent"
android:layout_alignParentTop="true"
android:layout_gravity="right"
android:background="@color/setting_background"
android:orientation="vertical" >
<ListView
android:id="@+id/newslist_drawer"
android:layout_width="wrap_content"
android:layout_height="0dip"
android:layout_alignParentTop="true"
android:layout_gravity="right"
android:layout_weight=".95"
android:background="@color/setting_background"
android:cacheColorHint="@android:color/transparent"
android:choiceMode="singleChoice"
android:divider="@android:color/transparent"
android:dividerHeight="0dp" />
<LinearLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="@+id/newslist_drawer"
android:layout_alignParentBottom
android:layout_weight=".05" >
<Button
android:id="@+id/newslist_done"
android:layout_width="0dip"
android:layout_height="wrap_content"
android:layout_weight="0.5"
android:text=" Done "
tools:ignore="NestedWeights" />
<Button
android:id="@+id/newslist_cancel"
android:layout_width="0dip"
android:layout_height="wrap_content"
android:layout_weight="0.5"
tools:ignore="NestedWeights"
android:text=" Cancel " />
</LinearLayout>
</LinearLayout>
试试看说伙计。快乐的编码:)