How to do setNestedScrollView in versions prior to Lollipop?

0

I would like to be able to do a NestedScrollView adapted to versions before Lollipop (API 21) and I am trying to follow the following tutorial:

link

but I still can not scroll in the text, I use a very simple framework and it does not give problems if I use the setNestedScrollView method for Lollipop or higher:

link

Below I leave my code so that my error can be corrected:

-------- > item_image_parallax2.xml

 <FrameLayout
        android:layout_width="match_parent"
        android:layout_height="wrap_content">

        <android.support.v7.widget.CardView 
xmlns:android="http://schemas.android.com/apk/res/android"
            xmlns:card_view="http://schemas.android.com/apk/res-auto"
            android:id="@+id/cv"
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            card_view:cardCornerRadius="@dimen/cardview_default_radius"
            card_view:cardElevation="@dimen/cardview_default_elevation"
            card_view:cardUseCompatPadding="true">

            <ScrollView
                android:layout_width="wrap_content"
                android:layout_height="wrap_content">

                <android.support.v4.widget.NestedScrollView
                    android:layout_width="wrap_content"
                    android:layout_height="wrap_content">

                    <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
                        android:layout_width="match_parent"
                        android:layout_height="wrap_content"
                        android:orientation="vertical"
                        android:paddingBottom="12dp"
                        android:paddingLeft="@dimen/activity_horizontal_margin"
                        android:paddingRight="@dimen/activity_horizontal_margin"
                        android:paddingTop="24dp">


                        <com.bluejamesbond.text.DocumentView
                            android:id="@+id/dv"
                            android:layout_width="match_parent"
                            android:layout_height="75dp"
                            android:layout_gravity="center"
                            android:scrollbarStyle="insideInset"
                            android:textAppearance="@style/TextAppearance.AppCompat.Body1">

                        </com.bluejamesbond.text.DocumentView>


                    </LinearLayout>

                </android.support.v4.widget.NestedScrollView>
            </ScrollView>
        </android.support.v7.widget.CardView>


    </FrameLayout>

Let's say that the xml above I use in a joint Viewgroup to another XML that I leave below:

------------------ > header.xml

<LinearLayout
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:orientation="vertical"
android:layout_width="match_parent"
android:layout_height="match_parent">

<ListView
    android:focusableInTouchMode="false"
    android:drawSelectorOnTop="true"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:id="@+id/listViewId"
    android:fastScrollEnabled="true"
    android:scrollbarStyle="outsideOverlay" />
</LinearLayout>

I use the following code in the activity (extends from AppCompatActivity):

LayoutInflater inflater = getLayoutInflater();
        ViewGroup header = (ViewGroup) inflater.inflate(R.layout.item_image_parallax2, list, false);
        image = (ImageView) header.findViewById(R.id.image);
        list.addHeaderView(header, null, false);
    
asked by M. Mariscal 08.03.2016 в 19:28
source

2 answers

1

I do not see any problems in the Layout, you can not see that the scroll is done since you have only one element and also it only has a height of 75dp :

   <com.bluejamesbond.text.DocumentView
                            android:id="@+id/dv"
                            android:layout_width="match_parent"
                            android:layout_height="75dp"
                            android:layout_gravity="center"
                            android:scrollbarStyle="insideInset"
                            android:textAppearance="@style/TextAppearance.AppCompat.Body1">

                        </com.bluejamesbond.text.DocumentView>

To prove that the scroll is successful, change android:layout_height to about 1000dp:

   <com.bluejamesbond.text.DocumentView
      ...         
    android:layout_height="1000dp"
   </com.bluejamesbond.text.DocumentView>

As a conclusion, your layout is correct and you can perform the vertical scroll.

    
answered by 08.03.2016 / 23:59
source
2

SOLVED!

I could not go to sleep without doing it ... Let's say that the problem I had before was that if I could scroll but with one finger press the text and with the other pull up or down to scroll. Now it does it as it should, if you press with a finger on the text and drag it moves, the TextView logic of any text that you can not see ... I leave the XML code below:

<FrameLayout
    android:layout_width="match_parent"
    android:layout_height="wrap_content">

    <android.support.v7.widget.CardView xmlns:card_view="http://schemas.android.com/apk/res-auto"
        android:id="@+id/cv"
        android:layout_width="match_parent"
        android:layout_height="100dp"
        android:fitsSystemWindows="true"
        android:isScrollContainer="true"
        card_view:cardCornerRadius="@dimen/cardview_default_radius"
        card_view:cardElevation="@dimen/cardview_default_elevation"
        card_view:cardUseCompatPadding="true">

        <android.support.v4.widget.NestedScrollView
            android:layout_width="match_parent"
            android:layout_height="wrap_content">

            <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
                android:layout_width="match_parent"
                android:layout_height="match_parent"
                android:paddingBottom="12dp"
                android:gravity="center"
                android:paddingLeft="@dimen/activity_horizontal_margin"
                android:paddingRight="@dimen/activity_horizontal_margin"
                android:paddingTop="20dp">

                <com.bluejamesbond.text.DocumentView
                    android:id="@+id/dv"
                    android:layout_width="match_parent"
                    android:layout_height="match_parent"
                    android:layout_gravity="center"
                    android:scrollbarStyle="insideInset"
                    android:textAppearance="@style/TextAppearance.AppCompat.Body2"/>

            </LinearLayout>
        </android.support.v4.widget.NestedScrollView>
    </android.support.v7.widget.CardView>
</FrameLayout>

I hope you'll be curious about someone!

    
answered by 10.03.2016 в 00:50