Set android:windowIsFloating programmatically Set android:windowIsFloating programmatically xml xml

Set android:windowIsFloating programmatically


One possible solution is to create a new style with only the windowIsFloating attribute set. Then, overwrite the getTheme method on your targeted activity in order to set that style. (Assuming AppTheme.NoActionBar is you current style).

styles.xml

<style name="MyCustomStyle" parent="AppTheme.NoActionBar">    <item name="android:windowIsFloating">true</item></style>

TargetActivity.java

@Overridepublic Resources.Theme getTheme() {    Resources.Theme theme = super.getTheme()    theme.applyStyle(R.style. MyCustomStyle, true)    return theme}