android - ScrollView not scrolling to the end of inner LinearLayout's bottom margin -
i'm having issues fragment consisting of scrollview containing linearlayout. i'm trying create effect linearlayout has white background , looks piece of paper scrolling on coloured background. way i'm trying achieve having scrollview occupy full space of fragment , linearlayout inside has android:layout_margin="16dp"
create space around "paper".
this way, scroll bar of scrollview appears in coloured background area, margin @ top scrolls away along content , margin @ bottom scrolls in when 1 reaches end.
unfortunately in configuration scrollview won't scroll way end , in fact cuts off small amount of text @ bottom. suspect scrollview isn't taking account child's margins in vertical scrolling distance. solve i've wrapped linearlayout in framelayout solves issue, seems superfluous. pointers on how eliminate unneeded container appreciated.
note: setting android:padding="16dp"
on scrollview , scrapping margins doesn't have desired effect, padding appears on 4 edges continuously, regardless of scroll position.
<?xml version="1.0" encoding="utf-8"?> <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" > <!-- framelayout exists purely force outer scrollview respect margins of linearlayout --> <framelayout android:layout_width="fill_parent" android:layout_height="wrap_content"> <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" > <textview android:id="@+id/article_title" android:layout_width="fill_parent" android:layout_height="wrap_content" android:textappearance="?android:attr/textappearancelarge" android:textisselectable="true" /> <textview android:id="@+id/article_content" android:layout_width="fill_parent" android:layout_height="wrap_content" android:textisselectable="true" /> </linearlayout> </framelayout> </scrollview>
i remember having trouble scrollview
somehow not making end of it's contents when content layout had top margin. solved problem little hack, adding empty view end of linearlayout
:
<?xml version="1.0" encoding="utf-8"?> <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="fill_parent" tools:context=".articlefragment" > <linearlayout android:layout_width="fill_parent" android:layout_height="wrap_content" android:orientation="vertical" android:padding="10dp" android:layout_margin="16dp" > <textview android:id="@+id/article_title" android:layout_width="fill_parent" android:layout_height="wrap_content" android:textappearance="?android:attr/textappearancelarge" android:textisselectable="true" android:background="@color/page_background" /> <textview android:id="@+id/article_content" android:layout_width="fill_parent" android:layout_height="wrap_content" android:textisselectable="true" android:background="@color/page_background" /> <!-- add little space end --> <view android:layout_width="fill_parent" android:layout_height="30dp" /> </linearlayout> </scrollview>
i used similar empty view in beginning of linearlayout
avoid top/bottom margins completely.
edit: realised wanted end of "paper" show when reaching end of view. in case might want set background color textview
s instead of layout itself. make sure there's no margin between title , article (use padding separation).
edit2: should learn check when questions asked... well, maybe still helps someone. :)
Comments
Post a Comment