Android中动态设置多继承Style/Theme
2017-04-19 13:11
761 查看
在Android中经常会使用继承style,举个例子:
这里设置了两个style
NoActionBar继承自AppTheme,如何应用NoActionBar?
xml中:
java中:
此时通过R.Style.AppTheme.NoActionBar是获取不到的,而是使用R.Style.AppTheme_NoActionBar,点已经被编译成下划线了。
所以,正确用法是setTheme(R.Style.AppTheme_NoActionBar)
Style同理,不再赘述。
这里设置了两个style
<style name="AppTheme" parent="Theme.AppCompat.Light.DarkActionBar"> <item name="colorPrimary">@color/colorPrimary</item> <item name="colorPrimaryDark">@color/colorPrimaryDark</item> <item name="colorAccent">@color/colorAccent</item> <item name="actionModeBackground">@color/colorPrimary </item> <item name="actionModeCloseDrawable">@drawable/ic_done_white_24dp</item> </style>
<style name="AppTheme.NoActionBar" > <item name="windowActionModeOverlay">true</item> <item name="windowActionBar">false</item> <item name="windowNoTitle">true</item> </style>
NoActionBar继承自AppTheme,如何应用NoActionBar?
xml中:
app:popupTheme="@style/AppTheme.NoActionBar"
java中:
此时通过R.Style.AppTheme.NoActionBar是获取不到的,而是使用R.Style.AppTheme_NoActionBar,点已经被编译成下划线了。
所以,正确用法是setTheme(R.Style.AppTheme_NoActionBar)
Style同理,不再赘述。
相关文章推荐
- android Theme Style 两种继承方式 以及优先级
- android Theme 设置为Android:style/Theme.Light.NoTitleBar.Fullscreen 程序秒退
- android:theme="@android:style/Theme.Light.NoTitleBar.Fullscreen"设置全屏程序闪退解决办法
- android全屏设置代码:android:theme="@android:style/Theme.NoTitleBar.Fullscreen"
- android:Style and Theme
- android:theme & android:style
- Android Dialog背景全透明无边框 Theme Style
- Android Style and Theme 样式和主题
- Android Style与Theme .
- android系统自带的主题与样式(theme and style)
- android theme & style
- Android Dialog背景全透明无边框 Theme Style
- android风格和主题:Style and Theme
- Android主题样式与风格(Theme and style)
- android:style/Theme
- Android Dialog背景全透明无边框 Theme Style
- android系统自带的主题与样式(theme and style)
- android 中系统自带的主题与样式(theme and style)
- android:theme="@android:style/Theme.NoTitleBar"
- android 中系统自带的主题与样式(theme and style)