我的应用程序中有一个自定义对话框,其编号从Activity
下降,并使用RelativeLayout
,其中所有位置和属性均由XML文件处理,而代码中没有任何属性。我的布局完全符合我的要求,但由于对话框中某些项目的长度,信息的某些行会换行到下一行。这不是一个问题,除了在这种情况下对话框中的关闭按钮看起来像是有人坐在它上面的事实。RelativeLayout中的奇怪按钮行为
这是从展示该按钮罚款模拟器截图,但我想在说明文字的右边一些填充,所以它不抵靠在该对话框的右侧:
看到这个,我将android:layout_marginRight="5dp"
添加到布局文件,希望得到我的保证金,这似乎是做 - 我得到我的包装 - 但按钮是不正确的。当我期待它时,对话框的高度不会改变,因为描述现在正在包装一条线。
这里是我的完整布局XML。这是我第一次使用RelativeLayout
,所以希望这是简单的我可以忽略。
<?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">
<ImageView
android:id="@+id/achievement_icon"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentTop="true"
android:layout_alignParentLeft="true"
android:layout_marginLeft="7dp"
android:contentDescription="@string/achievement_icon" />
<TextView
android:id="@+id/achievement_name"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginLeft="5dp"
android:layout_marginRight="5dp"
android:textColor="#ffffff"
android:textStyle="bold"
android:layout_toRightOf="@+id/achievement_icon" />
<TextView
android:id="@+id/achievement_gamerscore"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textColor="#ffffff"
android:textStyle="bold"
android:layout_marginLeft="5dp"
android:layout_below="@+id/achievement_name"
android:layout_toRightOf="@+id/achievement_icon" />
<TextView
android:id="@+id/achievement_description"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="7dp"
android:layout_marginRight="5dp"
android:layout_alignLeft="@+id/achievement_icon"
android:layout_below="@+id/achievement_icon" />
<TextView
android:id="@+id/achievement_earned"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="7dp"
android:layout_marginRight="5dp"
android:layout_alignLeft="@+id/achievement_description"
android:layout_below="@+id/achievement_description" />
<Button
android:id="@+id/cancel"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="7dp"
android:layout_centerHorizontal="true"
android:text="@string/button_close"
android:layout_below="@+id/achievement_earned" />
</RelativeLayout>