[Android]RelativeLayout中最底的View其layout_marginBottom无效

处理一个Dialog,发现RelativeLayout布局下最后一个View的layout_marginBottom会失效.
效果图见:


解决方法为:
在最底的组件后面再加个View吧...
这个现象挺特别的,发帖记录一下。

xml布局如下:

<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="fill_parent"
    android:layout_height="fill_parent"
    android:gravity="center"
    android:background="#80000000">
	<RelativeLayout
	    android:layout_width="match_parent"
	    android:layout_height="wrap_content"
	    android:id="@+id/dlgLayoutMain"
	    android:paddingBottom="18dp"
	    android:background="@drawable/micro_phone_dlg_bg">
	    <!-- 录音界面 -->
	    <TextView android:layout_width="wrap_content"
	        android:layout_height="wrap_content"
	        android:id="@+id/txtMicroPhoneHint"
	        android:layout_centerHorizontal="true"
	        android:layout_marginTop="25dp"
	        android:textSize="18.5sp"
	        android:textColor="#ff555555"
	        android:text="@string/micro_phone_what_2_say"/>
	    <!-- 话筒、音波 -->
	    <ImageView android:layout_width="wrap_content"
	        android:layout_height="wrap_content"
	        android:id="@+id/img_micro_phone"
	        android:background="@drawable/ic_launcher"
	        android:layout_below="@id/txtMicroPhoneHint"
	        android:layout_marginTop="15dp"
	        android:layout_centerHorizontal="true"/>
	    <Button android:layout_width="fill_parent"
	        android:layout_height="36dp"
	        android:id="@+id/btnPressed2Talk"
	        android:text="@string/aio_press_speak_label"
	        android:textSize="18.5sp"
	        android:textColor="#ffffff"
	        android:layout_below="@id/img_micro_phone"
	        android:layout_marginLeft="18dp"
	        android:layout_marginRight="18dp"
	        android:layout_marginTop="12dp"
	        android:layout_marginBottom="18dp"
	        android:layout_centerHorizontal="true"
	        android:background="#ff123456"
	        />
	    <!-- 把下面的view注释掉,则发现btnPressed2Talk的marginBottom无效 -->
	    <View android:layout_width="match_parent"
	        android:layout_height="0dp"
	        android:layout_below="@id/btnPressed2Talk"
	        />
	</RelativeLayout>
</RelativeLayout>

根据下面这段布局文件的代码帮我编辑出MainActivity的代码 <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" android:paddingBottom="@dimen/activity_vertical_margin" android:paddingLeft="@dimen/activity_horizontal_margin" android:paddingRight="@dimen/activity_horizontal_margin" android:paddingTop="@dimen/activity_vertical_margin" tools:context=".MainActivity" > <TextView android:id="@+id/textView1" android:layout_width="wrap_content" android:layout_height="wrap_content" android:text="请输入姓名" /> <EditText android:id="@+id/editText1" android:layout_width="match_parent" android:layout_height="wrap_content" android:layout_below="@+id/textView1" android:layout_centerHorizontal="true" android:ems="10" android:hint="在这里输入姓名" > <requestFocus /> </EditText> <EditText android:id="@+id/editText3" android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_alignParentBottom="true" android:layout_marginBottom="93dp" android:layout_toRightOf="@+id/button1" android:ems="10" android:inputType="date" /> <EditText android:id="@+id/editText2" android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_above="@+id/editText3" android:layout_centerHorizontal="true" android:layout_marginBottom="41dp" android:ems="10" /> <Button android:id="@+id/button1" android:layout_width="match_parent" android:layout_height="wrap_content" android:layout_above="@+id/editText2" android:layout_centerHorizontal="true" android:layout_marginBottom="20dp" android:text="按下" /> <EditText android:id="@+id/editText4" android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_alignParentBottom="true" android:layout_alignRight="@+id/editText2" android:layout_marginBottom="59dp" android:ems="10" android:inputType="date" /> </RelativeLayout>
07-22
评论 7
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值