title: How to use android:maxWidth?
body: <p>I want to set a maximum width of an edit box. So I created this small layout: </p>
  
  <pre><code>&lt;LinearLayout 
      xmlns:android="http://schemas.android.com/apk/res/android" 
      android:layout_width="fill_parent" 
      android:layout_height="wrap_content" 
      android:maxWidth="150dp" &gt; 
  
      &lt;EditText 
          android:layout_width="fill_parent" 
          android:layout_height="wrap_content" 
          android:ems="10" /&gt; 
  &lt;/LinearLayout&gt; 
  </code></pre>
  
  <p>But it doesn't work, the box could be more than 150 dp anyway. <code>android:maxWidth="150dp"</code> in the <code>EditText</code> will give the same result. I have read ( <a href="https://stackoverflow.com/questions/13325403/fill-parent-and-maxwidth-doesnt-work">maxWidth doesn&#39;t work with fill_parent</a> ) that setting both max- and min width to the same size should solve it:</p>
  
  <pre><code>&lt;EditText
          android:layout_width="wrap_content"
          android:layout_height="wrap_content"
          android:ems="10"
          android:maxWidth="50dp"
          android:minWidth="50dp" /&gt;
  </code></pre>
  
  <p>But it doesn't.</p>
  
  <p>I have found a solution to my problem here here: 
  <a href="https://stackoverflow.com/questions/5875877/setting-max-width-of-linearlayout-or-other-viewgroup-on-android/8619442#8619442">Setting a maximum width on a ViewGroup</a> 
  And this works great. But I guess the <code>maxWidth</code> attribute is here for I reason. How should it be used? Or is there any documentation on this? I have spend hours on this problem, and still doesn't understand how to use this simple attribute.</p>