How to auto scroll the ScrollView while drag and drop

两盒软妹~` 提交于 2019-12-10 10:14:29

问题


Too many answer was there in stackoverflow, I tried some of them but didn't get the solution. That's why I'm posting my code, please check and tell me where to put auto scroll.

<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:orientation="vertical"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="@color/button_text">

<android.support.v7.widget.Toolbar
    android:id="@+id/toolbar"
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    android:layout_alignParentTop="true"
    android:background="?attr/colorPrimary"
    android:elevation="6dp"
    android:minHeight="?attr/actionBarSize"
    android:theme="@style/ThemeOverlay.AppCompat.Dark.ActionBar"
    app:popupTheme="@style/ThemeOverlay.AppCompat.Light"/>

<RelativeLayout
    android:layout_width="wrap_content"
    android:layout_height="30dp"
    android:background="#3D3D3D"
    android:id="@+id/textrelative"
    android:layout_below="@+id/toolbar"
    android:layout_alignParentStart="true">

    <TextView
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:textColor="#ffffff"
        android:id="@+id/textView1"
        android:layout_centerVertical="true"
        android:layout_alignParentStart="true"
        android:textSize="7pt"
        android:paddingTop="2dp"
        android:paddingBottom="2dp"
        android:paddingLeft="10dp"
        android:textAppearance="?android:attr/textAppearanceMedium"
        android:text="Press and hold an item to rearrange"/>

</RelativeLayout>

<ScrollView
    android:id="@+id/mainScroll"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:layout_below="@+id/textrelative"
    android:layout_above="@+id/bottomLayout">

    <LinearLayout
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:padding="4dp"
        android:orientation="vertical">

        <editsetting.LinearLayoutListView
            android:id="@+id/pane1"
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:minHeight="50dp"
            android:layout_marginTop="0dp">

            <ListView
                android:id="@+id/listview1"
                android:layout_width="match_parent"
                android:layout_height="wrap_content">

            </ListView>

        </editsetting.LinearLayoutListView>

        <RelativeLayout
            android:layout_width="wrap_content"
            android:layout_height="30dp"
            android:layout_marginTop="0dp"
            android:layout_below="@+id/pane1"
            android:background="#f1f2f2"
            android:layout_alignParentStart="true">

            <TextView
                android:layout_width="match_parent"
                android:layout_height="wrap_content"
                android:textColor="#939393"
                android:id="@+id/textView"
                android:layout_centerVertical="true"
                android:layout_alignParentStart="true"
                android:textSize="7pt"
                android:paddingTop="2dp"
                android:paddingBottom="2dp"
                android:paddingLeft="10dp"
                android:textAppearance="?android:attr/textAppearanceMedium"
                android:text="Hidden"/>

        </RelativeLayout>

        <editsetting.LinearLayoutListView
            android:id="@+id/pane2"
            android:layout_width="match_parent"
            android:layout_height="match_parent"
            android:minHeight="100dp"
            android:layout_marginTop="0dp">

            <ListView
                android:id="@+id/listview2"
                android:layout_width="match_parent"
                android:layout_height="wrap_content">

            </ListView>

        </editsetting.LinearLayoutListView>

    </LinearLayout>

</ScrollView>

<LinearLayout
    android:id="@+id/bottomLayout"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:layout_alignParentBottom="true"
    android:orientation="horizontal"
    android:layout_alignParentEnd="true"
    android:layout_alignParentStart="true">

    <Button
        android:id="@+id/cancelbutton"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_weight="1"
        android:background="@drawable/button_border"
        android:textColor="#000"
        android:text="Cancel" />

    <Button
        android:id="@+id/doneButton"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_weight="1"
        android:background="@color/button_background"
        android:textColor="@color/button_text"
        android:text="Done"/>

</LinearLayout>

<android.support.design.widget.CoordinatorLayout
    android:id="@+id/coordinatorLayout"
    android:layout_width="match_parent"
    android:layout_height="match_parent">
</android.support.design.widget.CoordinatorLayout>

</RelativeLayout>

These is my xml what I have to do to make auto scroll in my java file.

with the help of these link i have created drag and drop

Now please help me out.

来源:https://stackoverflow.com/questions/34035916/how-to-auto-scroll-the-scrollview-while-drag-and-drop

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!