Denny Kurniawan
Denny Kurniawan

Reputation: 168

HorizontalScrollView Inside Nested Scrollview can't work

i am trying to make application can scrolled vertically, and inside my NestedScrollView and want put HorizontalView to scroll horizontal some of my TableLayout, Scrollview is working perfectly but the Horizontal Can't Scroll. How can i solve this? Thanks for your help.

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:background="#383735"
    android:baselineAligned="false">
    <android.support.v4.widget.NestedScrollView
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:id="@+id/vertical">
        <RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
            android:orientation="vertical" android:layout_width="match_parent"
            android:layout_height="match_parent"
            android:layout_margin="10dp">
            <TextView
                android:layout_width="130dp"
                android:layout_height="wrap_content"
                android:id="@+id/koded"
                android:textColor="#ffffff"
                android:text="Kode: "
                />
            <TextView
                android:layout_width="match_parent"
                android:layout_height="wrap_content"
                android:layout_toRightOf="@+id/koded"
                android:textColor="#ffffff"
                android:id="@+id/isikoded"/>
            <TextView

                android:layout_width="130dp"
                android:layout_height="wrap_content"
                android:layout_below="@id/isikoded"
                android:id="@+id/tglaju"
                android:textColor="#ffffff"
                android:text="Tgl Input: "
                android:layout_marginTop="10dp"/>
            <TextView
                android:layout_width="match_parent"
                android:layout_height="wrap_content"
                android:layout_toRightOf="@+id/tglaju"
                android:layout_below="@+id/isikoded"
                android:id="@+id/isitglaju"
                android:textColor="#ffffff"
                android:layout_marginTop="10dp"/>
            <TextView

                android:layout_width="130dp"
                android:layout_height="wrap_content"
                android:layout_below="@id/isitglaju"
                android:id="@+id/jpegawai"
                android:textColor="#ffffff"
                android:text="Pegawai: "
                android:layout_marginTop="10dp"/>
            <TextView
                android:layout_width="match_parent"
                android:layout_height="wrap_content"
                android:layout_toRightOf="@+id/jpegawai"
                android:layout_below="@+id/isitglaju"
                android:id="@+id/isipegawai"
                android:textColor="#ffffff"
                android:layout_marginTop="10dp"/>
            <TextView
                android:layout_width="130dp"
                android:layout_height="wrap_content"
                android:layout_below="@id/isipegawai"
                android:id="@+id/jdivisi"
                android:textColor="#ffffff"
                android:text="Divisi: "
                android:layout_marginTop="10dp"/>
            <TextView
                android:layout_width="match_parent"
                android:layout_height="wrap_content"
                android:layout_toRightOf="@+id/jdivisi"
                android:layout_below="@+id/isipegawai"
                android:id="@+id/isidivisi"
                android:textColor="#ffffff"
                android:layout_marginTop="10dp"/>

            <TextView
                android:layout_width="130dp"
                android:layout_height="wrap_content"
                android:layout_below="@id/isidivisi"
                android:id="@+id/tglbth"
                android:textColor="#ffffff"
                android:text="Tgl Penawaran: "
                android:layout_marginTop="10dp"
                />
            <TextView android:layout_marginTop="10dp"
                android:layout_width="match_parent"
                android:layout_height="wrap_content"
                android:layout_toRightOf="@+id/tglbth"
                android:layout_below="@+id/isidivisi"
                android:id="@+id/isitglbutuh"
                android:textColor="#ffffff"/>

            <TextView
                android:layout_width="130dp"
                android:layout_height="wrap_content"
                android:textColor="#ffffff"
                android:id="@+id/supd"
                android:layout_marginTop="10dp"
                android:text="No Penawaran: "
                android:layout_below="@+id/tglbth"
                android:layout_alignParentLeft="true"
                android:layout_alignParentStart="true" />
            <TextView
                android:layout_width="match_parent"
                android:layout_height="wrap_content"
                android:layout_below="@id/isitglbutuh"
                android:layout_toRightOf="@id/supd"
                android:id="@+id/isinomor"
                android:textColor="#ffffff"
                android:layout_marginTop="10dp"/>

            <HorizontalScrollView
                android:layout_width="match_parent"
                android:layout_height="wrap_content"
                android:layout_below="@id/isinomor"
                android:fillViewport="true"
                android:scrollbars="horizontal"
                android:nestedScrollingEnabled="false"
                android:scrollbarAlwaysDrawHorizontalTrack="true"
                android:id="@+id/horizontal">
                <LinearLayout
                    android:orientation="vertical"
                    android:layout_width="match_parent"
                    android:layout_height="match_parent">

            <TableLayout
                android:layout_width="match_parent"
                android:layout_height="wrap_content"
                android:layout_below="@+id/isinomor"
                android:id="@+id/tablejdl"
                android:weightSum="7"
                android:layout_marginTop="20dp"
                >
                <TableRow
                    android:layout_height="wrap_content"
                    android:layout_width="wrap_content"
                    android:weightSum="7"
                    android:gravity="center_horizontal">

                    <TextView
                        android:textColor="#ffffff"
                        android:layout_marginTop="10dp"

                        android:layout_width="0dp"
                        android:textSize="11sp"
                        android:layout_height="wrap_content"
                        android:text="Barang"
                        android:layout_weight="2"
                        android:id="@+id/kodebar"
                        />
                    <TextView
                        android:textColor="#ffffff"
                        android:layout_marginTop="10dp"

                        android:layout_width="0dp"
                        android:textSize="11sp"
                        android:layout_height="wrap_content"
                        android:text="Jumlah"
                        android:layout_weight="1"
                        android:id="@+id/jumlah"
                        />
                    <TextView
                        android:textColor="#ffffff"
                        android:layout_marginTop="10dp"

                        android:layout_width="0dp"
                        android:textSize="11sp"
                        android:layout_height="wrap_content"
                        android:text="Sup1"
                        android:layout_weight="1"
                        android:id="@+id/namabar"/>
                    <TextView
                        android:textColor="#ffffff"
                        android:layout_marginTop="10dp"

                        android:layout_width="0dp"
                        android:textSize="11sp"
                        android:layout_height="wrap_content"
                        android:text="Sup2"
                        android:layout_weight="1"
                        android:id="@+id/jumlahbar"/>

                    <TextView
                        android:textColor="#ffffff"
                        android:layout_marginTop="10dp"
                        android:layout_width="0dp"
                        android:textSize="11sp"
                        android:layout_height="wrap_content"
                        android:text="Sup3"
                        android:layout_weight="1"
                        android:id="@+id/stokbar"/>
                    <TextView
                        android:textColor="#ffffff"
                        android:layout_marginTop="10dp"

                        android:layout_width="0dp"
                        android:textSize="11sp"
                        android:layout_height="wrap_content"
                        android:text="Total"
                        android:layout_weight="1"
                        android:id="@+id/jtotal"/>
                </TableRow>
            </TableLayout>

                <android.support.v7.widget.RecyclerView
                    android:layout_width="match_parent"
                    android:layout_height="wrap_content"
                    android:layout_below="@id/tablejdl"
                    android:id="@+id/recyclerpenawaran">
                </android.support.v7.widget.RecyclerView>

            <TableLayout
                android:layout_width="match_parent"
                android:layout_height="match_parent"
                android:layout_below="@+id/dddd"
                android:id="@+id/tablejdl2"
                android:weightSum="7"
                android:layout_marginTop="15dp"
                >
                <TableRow
                    android:layout_height="wrap_content"
                    android:layout_width="wrap_content"
                    android:weightSum="7"
                    android:gravity="center_horizontal">

                    <TextView
                        android:textColor="#ffffff"
                        android:layout_marginTop="10dp"
                        android:layout_width="0dp"
                        android:textSize="11sp"
                        android:layout_height="wrap_content"
                        android:layout_weight="2"
                        />
                    <TextView
                        android:textColor="#ffffff"
                        android:layout_marginTop="10dp"
                        android:layout_width="0dp"
                        android:textSize="11sp"
                        android:layout_height="wrap_content"
                        android:layout_weight="1"

                        />
                    <CheckBox
                        android:textColor="#ffffff"
                        android:layout_marginTop="10dp"
                        android:layout_width="0dp"
                        android:textSize="11sp"
                        android:layout_height="wrap_content"
                        android:layout_weight="1"
                        android:id="@+id/checksup1"/>
                    <CheckBox
                        android:textColor="#ffffff"
                        android:layout_marginTop="10dp"
                        android:layout_width="0dp"
                        android:textSize="11sp"
                        android:layout_height="wrap_content"
                        android:layout_weight="1"
                        android:id="@+id/checksup2"/>

                    <CheckBox
                        android:textColor="#ffffff"
                        android:layout_marginTop="10dp"

                        android:layout_width="0dp"
                        android:textSize="11sp"
                        android:layout_height="wrap_content"

                        android:layout_weight="1"
                        android:id="@+id/checksup3"/>
                    <TextView
                        android:textColor="#ffffff"
                        android:layout_marginTop="10dp"
                        android:layout_width="0dp"
                        android:textSize="11sp"
                        android:layout_height="wrap_content"
                        android:text="Total"
                        android:layout_weight="1"
                        android:id="@+id/total"/>
                </TableRow>
            </TableLayout>
                </LinearLayout>
            </HorizontalScrollView>

            <RelativeLayout
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:layout_below="@id/horizontal"
                android:layout_marginTop="10dp"
                android:layout_marginLeft="10dp"
                android:layout_marginRight="10dp"
                android:layout_marginBottom="20dp"
                >
                <Button
                    android:layout_width="wrap_content"
                    android:layout_height="wrap_content"
                    android:text="Tolak"
                    android:id="@+id/tolak"
                    android:background="@drawable/buttonback2"
                    android:layout_alignParentRight="true"


                    />
                <Button
                    android:layout_width="wrap_content"
                    android:layout_height="wrap_content"
                    android:text="Approve"
                    android:layout_alignParentLeft="true"
                    android:id="@+id/btnapprove"
                    android:background="@drawable/buttonback"
                    />
            </RelativeLayout>

        </RelativeLayout>

    </android.support.v4.widget.NestedScrollView>
</LinearLayout>

Upvotes: 0

Views: 3233

Answers (2)

Harish Jangra
Harish Jangra

Reputation: 401

Set

android:nestedScrollingEnabled="true"

Upvotes: 1

Haresh Solanki
Haresh Solanki

Reputation: 31

Use:

android:nestedScrollingEnabled="false" 

it's working for me

Upvotes: 0

Related Questions