Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Set android:windowIsFloating programmatically

How can I set following activity style attribute programmatically

          <item name="android:windowIsFloating">true</item>
like image 839
Ahmed Emad Avatar asked Sep 14 '13 13:09

Ahmed Emad


Video Answer


1 Answers

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

@Override
public Resources.Theme getTheme() {
    Resources.Theme theme = super.getTheme()
    theme.applyStyle(R.style. MyCustomStyle, true)
    return theme
}
like image 86
diogenesgg Avatar answered Oct 05 '22 16:10

diogenesgg