android - PreferenceFragment inflated onto CardView -
i'm having difficulty getting layout_height right inflating preferencefragment onto cardview.
everything works well, including nestedscrollview collapse toolbar, reason preferences filling first position of list. it's scrollable, needs fill entire card.
any ideas on might going on here?
edit: it's nestedscrollview causing problem. if can find workaround..
i might not understand cards, since other layouts, can't seem them entirely fill view, minus little bit of margin.
here's preferencefragment xml
<android.support.v7.widget.cardview xmlns:app="http://schemas.android.com/apk/res-auto" xmlns:android="http://schemas.android.com/apk/res/android" xmlns:card_view="http://schemas.android.com/tools" android:id="@+id/cardview" android:layout_width="fill_parent" android:layout_height="fill_parent" android:elevation="100dp" android:layout_gravity="center" android:layout_margin="10dp" card_view:cardbackgroundcolor="@color/cardview_initial_background" card_view:cardcornerradius="10dp" app:layout_behavior="@string/appbar_scrolling_view_behavior"> <android.support.v4.widget.nestedscrollview android:id="@+id/nestedscrollview" android:layout_width="fill_parent" android:layout_height="fill_parent" android:padding="@dimen/scrollview_padding_default" > <linearlayout xmlns:android="http://schemas.android.com/apk/res/android" android:orientation="vertical" android:layout_height="fill_parent" android:layout_width="fill_parent" android:background="@android:color/transparent"> <listview android:id="@android:id/list" android:layout_width="fill_parent" android:layout_height="0px" android:layout_weight="1" android:paddingtop="0dip" android:paddingbottom="@dimen/preference_fragment_padding_bottom" android:paddingleft="@dimen/preference_fragment_padding_side" android:paddingright="@dimen/preference_fragment_padding_side" android:scrollbarstyle="@integer/preference_fragment_scrollbarstyle" android:cliptopadding="false" android:drawselectorontop="false" android:cachecolorhint="@android:color/transparent" android:scrollbaralwaysdrawverticaltrack="true" /> <textview android:id="@android:id/empty" android:layout_width="fill_parent" android:layout_height="fill_parent" android:padding="@dimen/preference_fragment_padding_side" android:gravity="center" android:visibility="gone" /> <relativelayout android:id="@+id/button_bar" android:layout_height="wrap_content" android:layout_width="fill_parent" android:layout_weight="0" android:visibility="gone"> <button android:id="@+id/back_button" android:layout_width="150dip" android:layout_height="wrap_content" android:layout_margin="5dip" android:layout_alignparentleft="true" android:text="@string/back_button_label"/> <linearlayout android:orientation="horizontal" android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_alignparentright="true"> <button android:id="@+id/skip_button" android:layout_width="150dip" android:layout_height="wrap_content" android:layout_margin="5dip" android:text="@string/skip_button_label" android:visibility="gone"/> <button android:id="@+id/next_button" android:layout_width="150dip" android:layout_height="wrap_content" android:layout_margin="5dip" android:text="@string/next_button_label"/> </linearlayout> </relativelayout> </linearlayout> </android.support.v4.widget.nestedscrollview> </android.support.v7.widget.cardview>
and preferencefragment java, inflation happens:
package app.my.sample; import android.os.bundle; import android.view.layoutinflater; import android.view.view; import android.view.viewgroup; import app.my.sample.r; public class settingspreferencefragment extends preferencefragment { public static final string arg_page = "arg_page"; private int mpage; public static settingspreferencefragment newinstance(int page) { bundle args = new bundle(); args.putint(arg_page, page); settingspreferencefragment fragment = new settingspreferencefragment(); fragment.setarguments(args); return fragment; } @override public void oncreate(bundle savedinstancestate) { super.oncreate(savedinstancestate); mpage = getarguments().getint(arg_page); addpreferencesfromresource(r.xml.preferences); } @override public view oncreateview(layoutinflater paramlayoutinflater, viewgroup paramviewgroup, bundle parambundle) { return paramlayoutinflater.inflate(r.layout.fragment_preference_list, paramviewgroup , false); //return super.oncreateview(paramlayoutinflater, paramviewgroup, parambundle); } }
it's old question maybe find answer useful. try adding attribute android:fillviewport="true"
nestedscrollview
.
Comments
Post a Comment