我需要创建一个活动,看起来像一个带圆角的对话框.
我设定了这个要求
android:theme="@android:style/Theme.Dialog"
Run Code Online (Sandbox Code Playgroud)
现在我的活动看起来像一个对话框,但我需要将其四舍五入.
然后我用属性创建了xml并将此drawable设置为我的活动主题,但现在我的活动看起来不像对话框.
请建议我可以做什么,以便我的活动看起来像带圆角的对话框.
Luk*_*rog 37
你可以制作自己的theme
圆角.首先,您需要一个drawable
为Activity
背景:
<?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>
Run Code Online (Sandbox Code Playgroud)
接下来制作扩展父级的主题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>
Run Code Online (Sandbox Code Playgroud)
这将在文件夹中命名styles.xml
的res/values
文件中.在Activity
你想要的Android清单中使用这个主题:
//...
<activity
android:name=".ActivityName"
android:label="@string/app_name"
android:theme="@style/ThemeWithCorners" >
//...
Run Code Online (Sandbox Code Playgroud)