[英]android dialog close button
I have an activity and I have set as a dialog using 我有一个活动,并且使用
<activity android:name=".ChangeUserImageActivity" android:theme="@android:style/Theme.Dialog"></activity>
How can I create a close button at the top right? 如何在右上角创建关闭按钮? Currently, my layout is as follows and I am using absolute layout...
目前,我的布局如下,并且我使用的是绝对布局...
<Button
android:id="@+id/closebtn"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_x="260px"
android:layout_y="5px"
android:text="X"
android:textSize="18sp"
android:onClick="close_click"
/>
Modify your current layout so the parent is a RelativeLayout
and then your Button
will look like this: 修改当前布局,使父级为
RelativeLayout
,然后您的Button
将如下所示:
<Button
android:id="@+id/closebtn"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentRight="true"
android:layout_alignParentTop="true"
android:text="X"
android:textSize="18sp"
android:onClick="close_click"
/>
And of course you'll have to modify your current layout to use the RelativeLayout
(the layout you didn't added to your question) 当然,您必须修改当前布局以使用
RelativeLayout
(您未添加到问题中的布局)
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.