java - 设置安卓 :windowIsFloating programmatically

标签 java android xml android-resources

如何以编程方式设置以下 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/

相关文章:

xml - 从 XPATH 后代值获取父节点

xml - JAXB 是否在内部使用 SAX 或 DOM?

java - 获取 Web 元素的绝对 XPath

java - JTable与SQL连接在eclipse中看不到结果

java - 按列名获取数据 apache poi excel

android - 如何运行 VtsHalWifiSupplicantV1_0Target 测试用例

java - 无法在 'java -version' 输出上进行 grep

android - 将街道地址转换为坐标android

android - 如何检测用户的键盘是否为 Swype?

java - 如何在具有特定属性的特定元素处写入 XML 文档?