Programmatically set android:windowIsTranslucent -


I was able to create floating activity after following this tutorial

However, For, I had to add this line to styles.xml :

  & item name = "android: windowIsTranslucent" & gt; True & lt; / Item & gt;   

Is it possible to use only Android / Java code to have the same effect? (For example, activity. Unprotected audio () or such ...)

Thank you in advance for your help.

[edit 01] styles.xml should not be changed (and I do not know what is in it ...). But for testing purposes, I am using the default:

  & lt; Resources & gt; & Lt; Style name = "appbashtheme" parent = theme "AppCompat.Light" & gt; & Lt; / Style & gt; & Lt; Style name = "Aaptim" parent = "appbashtheme" & gt; & Lt; / Style & gt; & Lt; / Resources & gt;  [edit 02]  I like what I want (according to the API description:  "value new features in the theme" ) So I created the following  custom_style.xml :  
    

Then, in On Attachtovondo () , I called:

  getTheme (). ApplyStyle (R.style.MyCustomStyle, true);   

But it has no effect ...

< P> Can this be the only effect using the Android / Java code?

I'm scared, no. You must do this in styles.xml the value of FIAIM's android: windowIsTranslucent can not be changed programmatically

when we < Code> super.onCreate (savedInstanceState); Activity class provides a blank graphical window on which we set our content ie.views. And a theme is applied on this subject and then the content is loaded on this view.

The sequence will be,

  1. super.onCreate ()
  2. to set the theme for the setting
  3. Setting Content View for that activity.

    For example.

    styles.xml

    & lt; Style name = "Aaptim" parent = "appbashtheme" & gt; & Lt ;! - All customizations that are not specific to a particular API-level can go here. - & gt; & Lt; Item Name = "Android: Window Background" & gt; @drawable / background & lt; / Item & gt; & Lt; Item name = "android: windowNoTitle" & gt; True & lt; / Item & gt; & Lt; / Style & gt; & Lt ;! - The application theme. Without title bar - & gt; & Lt; Style name = "Aaptim. None" parent = "appbashtheme" & gt; & Lt ;! - All customizations that are not specific to a particular API-level can go here. - & gt; & Lt; Item Name = "Android: Window Background" & gt; @drawable / background & lt; / Item & gt; & Lt; Item name = "android: windowNoTitle" & gt; True & lt; / Item & gt; & Lt; / Style & gt; & Lt ;! - floating activity subject - & gt; & Lt; Style name = "Theme_Translucent" parent = "Android: Style / Theme. No Title Bore." Fullscreen "& gt; & Lt; Item Name = "Android: Window Background" & gt; @Android: Color / Transparent & lt; / Item & gt; & Lt; Item name = "android: windowFrame" & gt; @ Null & lt; / Item & gt; & Lt; Item name = "android: windowContentOverlay" & gt; @ Null & lt; / Item & gt; & Lt; Item name = "android: windowIs floating" & gt; True & lt; / Item & gt; & Lt; Item name = "android: backgroundDimEnabled" & gt; True & lt; / Item & gt; & Lt; Item name = "android: windowIsTranslucent" & gt; True & lt; / Item & gt; & Lt; Item name = "android: windowNoTitle" & gt; True & lt; / Item & gt; & Lt; Item name = "android: windowAnimationStyle" & gt; @Android: style / animation Dialog & lt; / Item & gt; & Lt; Item name = "Android: Window fullscreen" & gt; True & lt; / Item & gt; & Lt; / Style & gt;

    Then set your theme to floating activity as follows:

      Crate on public void (bundled saved instenstate) {Super.onCreate (savedInstanceState); SetTheme (R.style.Theme_Translucent); // Set SetCentureview (...)}    

Comments

Popular posts from this blog

ios - Adding an SKSpriteNode to SKScene from a child SKSpriteNode -

Matlab transpose a table vector -

c# - Textbox not clickable but editable -