Defining android activity as dialog with light theme

北战南征 提交于 2019-12-30 10:08:25

问题


In my application I am defining one android activity as dialog.It looks proper.Only problem with that is my dialog appear in dark theme. I want to display it into light theme. I defined my activity dialog in following manner :

<activity
    android:theme="@android:style/Theme.DeviceDefault.Dialog.MinWidth"
    android:name="com.example.dialog"
    android:label="@string/title_activity_list" 
    >
</activity>

How to do this. Any solution. Need Help. Thank you.


回答1:


You need to use Holo Light Dialog theme:

<activity
    android:theme="@android:style/Theme.Holo.Light.Dialog"
    android:name="com.example.dialog"
    android:label="@string/title_activity_list" />



回答2:


Way around is to define custom theme into style xml, check below code:-

Style:

<style name="Theme.D1NoTitleDim" parent="android:style/Theme.Translucent">
<item name="android:windowNoTitle">true</item>
<item name="android:windowContentOverlay">@null</item>
<item name="android:backgroundDimEnabled">true</item>
<item name="android:background">#22000000</item>
</style>

manifest:

<activity
   android:theme="@style/Theme.D1NoTitleDim"
    android:name="com.example.dialog"
    android:label="@string/title_activity_list" 
    >
</activity>



回答3:


This also have worked for me. I have my app theme applied for the dialog activity.

<style name="Theme.UserDialog" parent="@style/MyAppTheme">
    <item name="android:windowFrame">@null</item>
    <item name="android:windowIsFloating">true</item>
    <item name="android:windowIsTranslucent">true</item>
    <item name="android:windowNoTitle">true</item>
</style>



回答4:


try this may be help you

<activity
    android:theme="@android:style/Theme_Wallpaper"
    android:name="com.example.dialog"
    android:label="@string/title_activity_list" 
    >
</activity>


来源:https://stackoverflow.com/questions/18525407/defining-android-activity-as-dialog-with-light-theme

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!