title: Setting style for dynamically added buttons
body: <p>I'm trying to set the style to a dynamically added buttons in an activity but the buttons are still with the default stlye. </p>
  
  <p>Here is <strong>my activity</strong></p>
  
  <pre><code>package com.sample.Learn_German_Quiz;
  
  import android.content.Context;
  import android.content.Intent;
  import android.graphics.Color;
  import android.support.v7.app.AppCompatActivity;
  import android.os.Bundle;
  import android.support.v4.view.ViewPropertyAnimatorCompat;
  import android.view.ContextThemeWrapper;
  import android.view.View;
  import android.view.ViewGroup;
  import android.widget.Button;
  import android.widget.LinearLayout;
  import android.widget.RelativeLayout;
  import android.widget.Toast;
  
  import static android.R.interpolator.linear;
  
  
  public class LessonChooserActivity extends AppCompatActivity {
  
      private GrammarBank grammarBank = new GrammarBank();
  
      public String getSelectedLesson() {
          return selectedLesson;
      }
  
      public void setSelectedLesson(String selectedLesson) {
          this.selectedLesson = selectedLesson;
      }
  
      private String selectedLesson;
  
      @Override
      protected void onCreate(Bundle savedInstanceState) {
          super.onCreate(savedInstanceState);
          setContentView(R.layout.activity_lesson_chooser);
          grammarBank.initLessons(getApplicationContext());
          setupButton();
  
  
      }
  
  
      private void setupButton() {
  
  
          Context newContext = new ContextThemeWrapper(getBaseContext(), R.style.button_learn);
  
          for (int i = 0; i &lt;= 5; i++) {
              LinearLayout layout = (LinearLayout) findViewById(R.id.linearTest);
              layout.setOrientation(LinearLayout.VERTICAL);
  
              Button btn = new Button(newContext);
              //Button btn = new Button(this);
              btn.setText(grammarBank.getLessonTitle(i));
              layout.addView(btn);
          }
  
  
      }
  
  
  }
  </code></pre>
  
  <p>and the <strong>layout</strong> file for the <strong>activity</strong> </p>
  
  <pre><code> &lt;LinearLayout
          android:layout_width="wrap_content"
          android:layout_height="match_parent"
          android:padding="@dimen/fab_margin"
          android:id="@+id/linearTest"&gt;
  
      &lt;Button
          style="@style/button_learn"
          android:layout_width="match_parent"
          android:layout_height="wrap_content"
          android:id="@+id/ButtonTest"
          android:ems="10"
          android:text="Test"
          android:textColor="#ffff"
          android:padding="16dp"
          android:onClick="onClick"
  
          /&gt;
  
      &lt;/LinearLayout&gt;
  </code></pre>
  
  <p>and the <strong>style</strong> I want to give to my buttons:</p>
  
  <pre><code> &lt;style name="button_learn" parent="Theme.AppCompat.DayNight.NoActionBar"&gt;
          &lt;item name="android:background"&gt;@drawable/button_rounded&lt;/item&gt;
          &lt;item name="android:layout_margin"&gt;20dp&lt;/item&gt;
      &lt;/style&gt;
  </code></pre>
  
  <p><strong>button_rounded.xml</strong> file </p>
  
  <pre><code>&lt;?xml version="1.0" encoding="utf-8"?&gt;
  &lt;selector xmlns:android="http://schemas.android.com/apk/res/android"&gt;
  &lt;item&gt;
      &lt;shape android:shape="rectangle"&gt;
          &lt;corners android:radius="50dp"&gt;&lt;/corners&gt;
           &lt;solid android:color="#4F535F"&gt;&lt;/solid&gt;
  
      &lt;/shape&gt;
  
  &lt;/item&gt;
  
  
  &lt;/selector&gt;
  </code></pre>
  
  <p>They are showing like this:</p>
  
  <p><a href="https://i.stack.imgur.com/ULtoE.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/ULtoE.png" alt="enter image description here"></a></p>
  
  <p>and I want them like this: </p>
  
  <p><a href="https://i.stack.imgur.com/QrHol.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/QrHol.png" alt="enter image description here"></a></p>