
我希望有一个活动,包括一个关闭按钮,即右上角关闭活动的’x’.任何关于此的例子都会非常有用.
解决方法:
在清单中使用透明主题制作活动,如下所示:
<activity androID:name=".MyDialogActivity" androID:theme="@style/theme.transparent" />然后像这样定义布局:
<?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"> <relativeLayout androID:orIEntation="vertical" androID:layout_wIDth="fill_parent" androID:layout_height="fill_parent" androID:layout_margin="15dp" androID:@R_403_5095@="2dp"> <!-- Contents will go here..--> </relativeLayout> <button androID:layout_alignParentRight="true" androID:text="X" androID:textcolor="#FFF" androID:background="@drawable/round_button_background" androID:gravity="center_vertical|center_horizontal" androID:layout_margin="5dp" androID:layout_height="25dp" androID:layout_wIDth="25dp" androID:textSize="12sp" androID:textStyle="bold" androID:onClick="cancelActivity" /></relativeLayout>并在drawable中定义关闭button的背景,如下所示:
round_button_background.xml<?xml version="1.0" enCoding="utf-8"?><shape xmlns:androID="http://schemas.androID.com/apk/res/androID" androID:shape="oval"> <solID androID:color="#9F2200" /> <stroke androID:wIDth="2dp" androID:color="#FFF" /></shape> 总结 以上是内存溢出为你收集整理的如何通过顶部的关闭按钮在Android中进行活动?全部内容,希望文章能够帮你解决如何通过顶部的关闭按钮在Android中进行活动?所遇到的程序开发问题。
如果觉得内存溢出网站内容还不错,欢迎将内存溢出网站推荐给程序员好友。
欢迎分享,转载请注明来源:内存溢出
微信扫一扫
支付宝扫一扫
评论列表(0条)