title: How to set width/height for any widget through Theme in Android
body: <p>I need to use same widgets(buttons,editext,textviews) with same properties like width,height,textColor,size etc in multiple screens (xmls). So I created styles for individual widgets (one style for button, one for edit text ...) and I defined all these styles in my CustomTheme.</p>
  
  <p>My Problem is</p>
  
  <p>If I define layout width/height also in styles and simply giving style="@style/myButtonStyle" for button in xml is working fine even though I did n't mention width/height in xml (might be inheriting from Style). </p>
  
  <p>If I give width/height in xml without style prop and simply giving my Custom theme to activity is bringing all styles I specified in theme. But I did n't mention width/height in xml it is raising an exception saying that u have specify layout width/height, which I already specified in style itself.</p>
  
  <p>my theme file is </p>
  
  <pre><code> &lt;style name="Theme.Blue" parent="android:Theme"&gt;
   &lt;item name="android:buttonStyle"&gt;@style/button222&lt;/item&gt;
  &lt;item name="android:textViewStyle"&gt;@style/text222&lt;/item&gt;
  &lt;item name="android:editTextStyle"&gt;@style/edittext222&lt;/item&gt;
  &lt;/style&gt;
  </code></pre>
  
  <p>and my button222 style is</p>
  
  <pre><code> &lt;style name="button222" parent="@android:style/Widget.Button"&gt;
  &lt;item name="android:layout_width"&gt;@dimen/mWidth&lt;/item&gt;
  &lt;item name="android:textColor"&gt;#F56266&lt;/item&gt;
  &lt;item name="android:textSize"&gt;20sp&lt;/item&gt;
  &lt;/style&gt;
  </code></pre>
  
  <p>and I specified dimension as </p>
  
  <pre><code>       &lt;dimen name="mWidth"&gt;180dip&lt;/dimen&gt;
  </code></pre>
  
  <p>and I used like this in layout.xml</p>
  
  <pre><code>                          &lt;Button   android:layout_width="180dip"
                  android:layout_height="wrap_content"
                  android:text="This is large text."
                  /&gt;
  
              &lt;Button
                  android:layout_height="wrap_content"
                  android:text="This is regular text one"
                  /&gt;
  
              &lt;Button
                  style="@style/button222"
                  android:layout_height="wrap_content"
                  android:text="This is regular text."
                  /&gt;
  </code></pre>
  
  <p>and it is giving exception saying specify layout width, which I mentioned in button222 style and trying to use through my theme.</p>