垂直 recyclerView 和 Horizo​​ntal recyclerview 一起滚动

在我的项目中,Recyclerview如果我(垂直)滚动屏幕,我想要两个(第一个水平和第二个垂直)我希望它们两个一起滚动。

http://img1.mukewang.com/629b22f50001b46303600640.jpg

我尝试了一些方法但没有奏效请帮助我


我的片段 xml


<?xml version="1.0" encoding="utf-8"?>

<ScrollView xmlns:android="http://schemas.android.com/apk/res/android"

    xmlns:tools="http://schemas.android.com/tools"

    android:layout_width="match_parent"

    android:layout_height="match_parent"

    tools:context=".Fragments.Tabs.FarsiF.FarsiBadr">


    <LinearLayout

        android:layout_width="match_parent"

        android:layout_height="wrap_content"

        android:orientation="vertical">



        <android.support.v7.widget.RecyclerView

            android:id="@+id/recyclerview_id_Horizental_badr_farsi"

            android:layout_width="match_parent"

            android:layout_height="wrap_content"></android.support.v7.widget.RecyclerView>


        <android.support.v7.widget.RecyclerView

            android:id="@+id/recyclerview_id_vertical_badr_farsi"

            android:layout_width="match_parent"

            android:layout_height="match_parent">


        </android.support.v7.widget.RecyclerView>

    </LinearLayout>

</ScrollView>

我的片段类


public class FarsiBadr extends Fragment {

    RecyclerViewAdapter myAdapter;

    List<Items> lstItems;

    public FarsiBadr() {

        // Required empty public constructor

    }

    @Override

    public View onCreateView(LayoutInflater inflater, ViewGroup container,Bundle savedInstanceState) {

        // Inflate the layout for this fragment

        View view = inflater.inflate(R.layout.fragment_farsi_badr, container, false);

        lstItems = new ArrayList<>();

    }


}


阿晨1998
浏览 125回答 1
1回答

慕容森

只要改成scrollview你<android.support.v4.widget.NestedScrollView 就可以解决你的问题尝试这个<?xml version="1.0" encoding="utf-8"?><android.support.v4.widget.NestedScrollView xmlns:android="http://schemas.android.com/apk/res/android"&nbsp; &nbsp; xmlns:tools="http://schemas.android.com/tools"&nbsp; &nbsp; android:layout_width="match_parent"&nbsp; &nbsp; android:layout_height="match_parent"&nbsp; &nbsp; tools:context=".multi.TabFragment">&nbsp; &nbsp; <LinearLayout&nbsp; &nbsp; &nbsp; &nbsp; android:layout_width="match_parent"&nbsp; &nbsp; &nbsp; &nbsp; android:layout_height="wrap_content"&nbsp; &nbsp; &nbsp; &nbsp; android:orientation="vertical">&nbsp; &nbsp; &nbsp; &nbsp; <EditText&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; android:id="@+id/searchintabbadrkurdi"&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; android:layout_width="match_parent"&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; android:layout_height="wrap_content" />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <android.support.v7.widget.RecyclerView&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; android:id="@+id/recyclerview_id_badr_kurdish_hor"&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; android:layout_width="match_parent"&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; android:layout_height="wrap_content">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </android.support.v7.widget.RecyclerView>&nbsp; &nbsp; &nbsp; &nbsp; <android.support.v7.widget.RecyclerView&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; android:id="@+id/recyclerview_id_badr_kurdish"&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; android:layout_width="match_parent"&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; android:layout_height="match_parent">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </android.support.v7.widget.RecyclerView>&nbsp; &nbsp; </LinearLayout></android.support.v4.widget.NestedScrollView>
打开App,查看更多内容
随时随地看视频慕课网APP

相关分类

Java