如何以编程方式设置以下 Activity 样式属性
<item name="android:windowIsFloating">true</item>
最佳答案
一个可能的解决方案是创建一个仅设置了 windowIsFloating
属性的新样式。然后,覆盖目标 Activity 的 getTheme
方法以设置该样式。 (假设 AppTheme.NoActionBar
是您当前的风格)。
styles.xml
<style name="MyCustomStyle" parent="AppTheme.NoActionBar">
<item name="android:windowIsFloating">true</item>
</style>
TargetActivity.java
@Override
public Resources.Theme getTheme() {
Resources.Theme theme = super.getTheme()
theme.applyStyle(R.style. MyCustomStyle, true)
return theme
}
关于java - 设置安卓 :windowIsFloating programmatically,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/18802041/