Note that there are some explanatory texts on larger screens.

plurals
  1. POScrollView not scrolling to the end of inner LinearLayout's bottom margin
    primarykey
    data
    text
    <p>I'm having issues with a Fragment consisting of a ScrollView containing a LinearLayout. I'm trying to create an effect where the LinearLayout has a white background and looks like a piece of paper scrolling on a coloured background. The way that I'm trying to achieve this is by having the ScrollView occupy the full space of the fragment and then the LinearLayout inside has <code>android:layout_margin="16dp"</code> to create the space around the "paper".</p> <p>This way, the scroll bar of the ScrollView appears in the coloured background area, the margin at the top scrolls away along with the content and the margin at the bottom only scrolls in when one reaches the end.</p> <p>Unfortunately in this configuration the ScrollView won't scroll all the way to the end and in fact cuts off a very small amount of the text at the bottom. I suspect that the ScrollView isn't taking into account its child's margins in its vertical scrolling distance. To solve this I've wrapped the LinearLayout in a FrameLayout which solves the issue, but seems superfluous. Any pointers on how to eliminate this unneeded container would be appreciated.</p> <p>Note: setting <code>android:padding="16dp"</code> on the ScrollView and scrapping the margins doesn't have the desired effect, as then the padding appears on all four edges continuously, regardless of scroll position.</p> <pre><code>&lt;?xml version="1.0" encoding="utf-8"?&gt; &lt;ScrollView 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" tools:context=".ArticleFragment" &gt; &lt;!-- This FrameLayout exists purely to force the outer ScrollView to respect the margins of the LinearLayout --&gt; &lt;FrameLayout android:layout_width="fill_parent" android:layout_height="wrap_content"&gt; &lt;LinearLayout android:layout_width="fill_parent" android:layout_height="wrap_content" android:orientation="vertical" android:padding="10dp" android:layout_margin="16dp" android:background="@color/page_background" &gt; &lt;TextView android:id="@+id/article_title" android:layout_width="fill_parent" android:layout_height="wrap_content" android:textAppearance="?android:attr/textAppearanceLarge" android:textIsSelectable="true" /&gt; &lt;TextView android:id="@+id/article_content" android:layout_width="fill_parent" android:layout_height="wrap_content" android:textIsSelectable="true" /&gt; &lt;/LinearLayout&gt; &lt;/FrameLayout&gt; &lt;/ScrollView&gt; </code></pre>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

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