android的Activity窗口模式
16lz
2022-07-21
androud的窗口模式,就是activity不占用整个的手机屏幕,以窗口的样式呈现出来。
你如果在manifest中该的话:
<application android:allowBackup="true" android:icon="@drawable/ic_launcher" android:label="@string/app_name" android:theme="@android:style/Theme.Dialog" >
这是直接的使用原生的窗口主题,默认的背景是黑色的。
这样看起来不是很美观的。那我们在Layout中,直接设置布局的背景为白色的话:
android:background="@android:color/white"
我们就可以看到,下面白色的部分就是布局的区域了,上面的黑色是项目的名称。
这样对下,我们就好区别屏幕区域到底是哪里了。
但我们想自己定义主题,那该咋办呢?
我们在style中,添加一个自定义主题,它的父主题是窗口模式:
<!-- Application theme. --> <style name="AppTheme" parent="android:Theme.Dialog"> <!-- All customizations that are NOT specific to a particular API-level can go here. --> <item name="android:background">@android:color/darker_gray</item> </style>
在这里我们只是改了下背景颜色,其他的根据需要,像一般的主题那样改就可以了。
更多相关文章
- Android中使Dialog显示时背景不变暗
- Hello Android(安卓)- android窗体透明的,黑暗度等的设置技巧
- android背景选择器selector用法汇总
- ListItem更改背景色
- 调出软键盘 挤掉标题栏咋办
- 样式 主题 对话框 国际化
- 【android开发】styles.xml常用的设置属性汇总
- Android(安卓)tabhost让选中项加上背景图
- Android背景图片平铺