Note that there are some explanatory texts on larger screens.

plurals
  1. POAndroid: programmatically added layout ignores theme
    text
    copied!<p>I have abstract <code>UltraSuperActivity</code> inherited by abstract <code>SuperActivity</code> inherited by <code>MyActivity</code>. In <code>OnCreate</code> of <code>SuperActivity</code> I call <code>setContentView(R.layout.activity_super);</code> which contains <code>HorizontalScrollLayout</code> into which I add the layout of current activity</p> <p>I add layout like this in <code>OnCreate</code> in <code>MyActivity</code>:</p> <pre><code>LinearLayout activity_layout = (LinearLayout)inflater.inflate(R.layout.activity_layout, null); HorizontalScrollView application_contents = (HorizontalScrollView)findViewById(R.id.application_contents); HorizontalScrollView.LayoutParams cp = new HorizontalScrollView.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.MATCH_PARENT); some more code... application_contents.addView(activity_layout, cp); </code></pre> <p>Inflater is set up in <code>UltraSuperActivity</code> as static:</p> <pre><code>if(inflater == null){ inflater = (LayoutInflater) getApplicationContext().getSystemService(Context.LAYOUT_INFLATER_SERVICE); inflater.setFactory(CustomViewFactory.getInstance()); // we add our factory for our views } </code></pre> <p>I am using <code>MyButton</code> style which as a theme is given to every button. That works in <code>activity_super</code> layout but it does not work in <code>activity_layout</code> and it is displayed as common Android button. Theme is set in <code>AndroidManifest.xml</code>. If I add <code>MyButton</code> style in the <code>activity_layout</code> to the button it works but I don't understand why it does not use the set up theme.</p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload