Note that there are some explanatory texts on larger screens.

plurals
  1. POAndroid - TextView ignoring "wrap_content"
    text
    copied!<p>I've got a problem with creating a layout in Android.</p> <p>I have a linear layout which should display a TextView, EditView and Button from Top to bottom. Problem is that when I set the width and height attribute of the TextView to "wrap_content" it behaves like "fill_parent" and fills the whole screen in width and height. As a conclusion the 2 other elements(EditView and Button) won't be shown.</p> <p>I just can't figure out what I am doing wrong.</p> <p>Here is my XML file:</p> <pre><code> &lt;LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="match_parent" android:layout_height="match_parent" android:background="@drawable/app_background" android:gravity="center_horizontal" android:orientation="vertical" &gt; &lt;TextView android:id="@+id/text_nickname" android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_marginTop="15dp" android:gravity="center_horizontal" android:text="@string/label_nickname" android:textColor="#000000" android:textSize="15sp" /&gt; &lt;EditText android:id="@+id/edit_nickname" android:layout_width="wrap_content" android:layout_height="wrap_content" android:hint="@string/hint_insert_nickname" android:shadowColor="#000000" android:shadowDx="-1" android:shadowDy="-1" android:shadowRadius="1" android:textSize="15sp" /&gt; &lt;Button android:id="@+id/button_play" style="@style/MainButtonTheme" android:layout_marginTop="25dp" android:onClick="click_playButton" android:text="@string/button_start" /&gt; &lt; / LinearLayout&gt; </code></pre> <p>Looking forward to your input.</p> <p>Lots of greetings</p> <p>Siggy</p> <p>Edit:</p> <p>MainButtonStyle:</p> <pre><code> &lt;style name="MainButtonTheme"&gt; &lt;item name="android:background"&gt;@drawable/states_menu_button&lt;/item&gt; &lt;item name="android:layout_width"&gt;wrap_content&lt;/item&gt; &lt;item name="android:layout_height"&gt;wrap_content&lt;/item&gt; &lt;item name="android:textSize"&gt;25sp&lt;/item&gt; &lt;item name="android:textColor"&gt;#000000&lt;/item&gt; &lt;item name="android:textStyle"&gt;bold&lt;/item&gt; &lt;/style&gt; </code></pre> <p>Edit #2:</p> <p>Here are the screenshots of how it looks like right now and what is desired:</p> <p>Current state:</p> <p><img src="https://i.stack.imgur.com/I4DJF.png" alt="enter image description here"></p> <p>Desired state:</p> <p><img src="https://i.stack.imgur.com/P3yLh.png" alt="enter image description here"></p> <p>I tested it on the phone and it looks like this on the phone as well.</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