PreferenceFragment overstated on CardView

I am having a hard time getting the layout_height right by inflating the PreferenceFragment on the CardView.

Everything works well, including the NestedScrollView to collapse my toolbar, but for some reason my settings only fill the first position of the list. It scrolls, but it needs to fill in the entire Map.

Any ideas on what might be going on here?

Edit: This is definitely a NestedScrollView issue. Now if only I can find a workaround.

I also might not be able to fully understand Maps, as other layouts, I cannot get them to completely fill the view, minus this little bit.

Here's my 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 my Java PreferenceFragment is where 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);

}

}

      

+3


source to share


1 answer


This is an old question, but maybe someone will find this answer helpful. Try adding the attribute android:fillViewport="true"

to NestedScrollView

.



+2


source







All Articles