如何让圆角对话框主题活动 [英] how to get rounded dialog theme for activity
问题描述
我需要创建它应该看起来像同一个圆角对话框中的活动。
I need to create a activity which should look like as a dialog box with a rounded corners.
对于这个要求我设置
android:theme="@android:style/Theme.Dialog"
现在我的活动看起来像一个对话框,但我需要它的边角是圆的。
Now my activity looks like a dialog box but I need its corners to be rounded.
然后,我创建的XML与属性,并将此作为绘制我的活动主题,但现在我的活动不是看起来像对话框。
Then I created xml with attribute and set this drawable as my activity theme but now my activity not looks like dialog box.
请建议我可以做些什么让我的行为看起来像圆角对话框。
Please suggest me what can be done so that my activity looks like dialog box with rounded corners.
推荐答案
您可以制作自己的主题
拥有圆角。首先,您需要一个绘制
为活动
背景:
You could make your own theme
that has rounded corners. First you'll need a drawable
for the Activity
background:
<?xml version="1.0" encoding="utf-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android" >
<corners android:radius="15dp" />
<solid android:color="#565656" />
<stroke
android:width="3dp"
android:color="#ffffff" />
<padding
android:bottom="6dp"
android:left="6dp"
android:right="6dp"
android:top="3dp" />
</shape>
下一页制作自己的主题,它扩展了父 Theme.Dialog
:
<?xml version="1.0" encoding="utf-8"?>
<resources>
<style name="ThemeWithCorners" parent="android:Theme.Dialog">
<item name="android:windowBackground">@drawable/another_test_drawable</item>
</style>
</resources>
这将是一个名为 styles.xml
在 RES /值
文件夹中的文件。使用这个主题,在Android清单的活动
你想要的:
This will be in a file named styles.xml
in the res/values
folder. Use this theme in the android manifest for the Activity
you want:
//...
<activity
android:name=".ActivityName"
android:label="@string/app_name"
android:theme="@style/ThemeWithCorners" >
//...
这篇关于如何让圆角对话框主题活动的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!