Note that there are some explanatory texts on larger screens.

plurals
  1. POCenter content in scroll view
    text
    copied!<p>I want to center my LinearLayout within ScrollView. When LinearLayout's height is small it's centered alright (see image #1) but when LinearLayout's height is bigger than the screen's height then it behaves strange. I cannot see the top of LinearLayout (see image #2) and at the bottom of ScrollView there's huge padding. I don't know what's happening here. When there are lots of content in LinearLayout the whole screen should look like in image #3. </p> <p><a href="https://i.imgur.com/NZ7ufsJ.png" rel="noreferrer">image #1</a><br> <a href="https://i.imgur.com/Xopxfz6.png" rel="noreferrer">image #2</a><br> <a href="https://i.imgur.com/py4pUWj.png" rel="noreferrer">image #3</a><br></p> <p>Here's my layout file:</p> <pre><code> &lt;?xml version="1.0" encoding="utf-8"?&gt; &lt;ScrollView xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="match_parent" android:layout_height="match_parent" android:background="#cccfff" &gt; &lt;LinearLayout android:layout_width="match_parent" android:layout_height="wrap_content" android:layout_gravity="center_vertical" android:layout_margin="28dp" android:background="#ffffff" android:orientation="vertical" android:paddingBottom="40dp" android:paddingLeft="20dp" android:paddingRight="20dp" android:paddingTop="40dp" &gt; &lt;ImageView android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_marginBottom="16dp" android:src="@drawable/ic_launcher" /&gt; &lt;TextView android:id="@+id/tip_title" android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_marginBottom="12dp" android:text="Title" android:textColor="@color/orange_text" android:textSize="@dimen/font_size_medium" /&gt; &lt;TextView android:id="@+id/tip_description" android:layout_width="wrap_content" android:layout_height="wrap_content" android:text="Description description..." android:textSize="@dimen/font_size_small" /&gt; &lt;/LinearLayout&gt; &lt;/ScrollView&gt; </code></pre>
 

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