Note that there are some explanatory texts on larger screens.

plurals
  1. POAndroid Layout - ListView taking too much space
    text
    copied!<p>Well hello there!</p> <p>I ran into a problem in Android (I am also new to Android). </p> <p>First of all I have 2 Fragments. 1 Fragment contains a ListView where I show the music on my phone. The 2nd Fragment has some controls. </p> <p><strong>I want that the Fragment with the Controls stays at the bottom of the screen. The ListFragment should stick to the top of the Activity. How can I do this?</strong></p> <p>Now I have made up the following in xml: activity_main.xml:</p> <pre><code>&lt;LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" xmlns:tools="http://schemas.android.com/tools" android:layout_width="match_parent" android:layout_height="match_parent" android:background="@drawable/rain" android:gravity="center|top" android:orientation="vertical" tools:context=".MainActivity" &gt; &lt;!-- Playlist --&gt; &lt;fragment android:id="@+id/playlist_fragment" android:layout_width="fill_parent" android:layout_height="0px" android:layout_gravity="top" android:layout_weight="6" class="at.wireless.musicstream.fragment.PlaylistFragment" /&gt; &lt;!-- Separator --&gt; &lt;View android:layout_width="match_parent" android:layout_height="2dp" android:background="@android:color/holo_blue_dark" /&gt; &lt;!-- Controls --&gt; &lt;fragment android:id="@+id/control_fragment" android:layout_width="fill_parent" android:layout_height="0px" android:layout_weight="1" class="at.wireless.musicstream.fragment.ControlFragment" /&gt; &lt;/LinearLayout&gt; </code></pre> <p>I used layout_weight here, but that's not what I want, because at different screen sizes this will also take up different height. But I want the controls to have a "fixed" size (I use dp in the Fragment)</p> <p>playlist_fragment.xml:</p> <pre><code>&lt;LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" xmlns:tools="http://schemas.android.com/tools" android:layout_width="wrap_content" android:layout_height="wrap_content" android:gravity="center|top" tools:context=".MainActivity" &gt; &lt;ListView android:id="@android:id/list" android:layout_height="match_parent" android:layout_width="match_parent" &gt; &lt;/ListView&gt; &lt;/LinearLayout&gt; </code></pre> <p>And my control_fragment.xml:</p> <pre><code>&lt;LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" xmlns:tools="http://schemas.android.com/tools" android:layout_width="fill_parent" android:layout_height="wrap_content" android:background="@android:color/transparent" android:orientation="horizontal" tools:context=".MainActivity" &gt; &lt;ImageView android:id="@+id/albumView" android:layout_width="70dp" android:layout_height="70dp" android:layout_gravity="left" android:background="@drawable/no_album_art" android:contentDescription="Album Art" /&gt; &lt;LinearLayout android:layout_width="wrap_content" android:layout_height="wrap_content" android:orientation="vertical"&gt; &lt;TextView android:id="@+id/actPlayingTitle" android:layout_width="wrap_content" android:layout_height="wrap_content" android:textSize="14sp" android:textIsSelectable="false" android:text="hier titel" android:textColor="@android:color/white"/&gt; &lt;TextView android:id="@+id/actPlayingArtist" android:layout_width="wrap_content" android:layout_height="wrap_content" android:textIsSelectable="false" android:textSize="12sp" android:text="hier artist" android:textColor="@android:color/white" /&gt;" &lt;/LinearLayout&gt; &lt;LinearLayout android:layout_width="wrap_content" android:layout_height="wrap_content" android:gravity="right" android:layout_marginLeft="20dp" &gt; &lt;Button android:id="@+id/rewindBtt" android:layout_width="40dp" android:layout_height="40dp" android:layout_gravity="right" android:background="@drawable/play" /&gt; &lt;Button android:id="@+id/playbackBtt" android:layout_width="40dp" android:layout_height="40dp" android:layout_gravity="right" android:background="@android:color/black" /&gt; &lt;Button android:id="@+id/skipBtt" android:layout_width="40dp" android:layout_height="40dp" android:layout_gravity="right" android:background="@android:color/white" /&gt; &lt;/LinearLayout&gt; &lt;/LinearLayout&gt; </code></pre> <p><a href="http://i.stack.imgur.com/m6iJH.png" rel="nofollow">Image</a></p> <p>The ListView should take the space that the control_fragment leaves. So lets say i have a total screen height of 1000. The controls take up 200, then the ListView has 800 left.</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