Ahm*_*mad 9 java xml android android-resources
如何以编程方式设置以下活动样式属性
<item name="android:windowIsFloating">true</item>
Run Code Online (Sandbox Code Playgroud)
一种可能的解决方案是创建仅包含windowIsFloating属性集的新样式。然后,覆盖getTheme目标活动的方法以设置该样式。(假设AppTheme.NoActionBar是您当前的风格)。
样式.xml
<style name="MyCustomStyle" parent="AppTheme.NoActionBar">
<item name="android:windowIsFloating">true</item>
</style>
Run Code Online (Sandbox Code Playgroud)
目标活动.java
@Override
public Resources.Theme getTheme() {
Resources.Theme theme = super.getTheme()
theme.applyStyle(R.style. MyCustomStyle, true)
return theme
}
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
1287 次 |
| 最近记录: |