0

私は Android アプリを開発しています。垂直の NestedScrollView を取得しました。垂直の NestedScrollView は、すべての画面を取り、複数の水平の RecyclerView 内にあります。作業ですが、水平スクロールを実現するのは非常に困難です。

つまり、水平方向にスクロールすると、ジェスチャーが NestedScrollView によってキャッチされ、ビューが上下に移動します。RecyclerViewをスクロールするには、焦点を合わせて実際の水平方向の動きをする必要があります.UXを殺しています...

ここで私の NestedScrollView :

<android.support.v4.widget.NestedScrollView
    android:id="@+id/scrollView"
    android:scrollbars="none"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:layout_marginTop="5dp"
    android:layout_marginEnd="5dp"
    android:layout_marginRight="5dp"
    android:layout_marginLeft="5dp"
    android:layout_marginStart="5dp">

    <LinearLayout
        android:layout_height="wrap_content"
        android:layout_width="match_parent"
        android:id="@+id/scrollLayout"
        android:orientation="vertical" />

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

数はネットワークデータで定義されているため、プログラムで RecyclerView を膨張させています。ここでは膨張したレイアウトです。

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

    <TextView
        android:textSize="@dimen/secondary_text_size"
        android:textAllCaps="true"
        android:layout_marginBottom="5dp"
        android:layout_marginTop="5dp"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content" />

    <android.support.v7.widget.RecyclerView
        android:id="@+id/recyclerView"
        android:layout_width="match_parent"
        android:layout_height="@dimen/recycler_view_size" />

</LinearLayout>

そして、Java で RecyclerView を設定する方法:

LayoutInflater inflater = LayoutInflater.from(context);
LinearLayout layout = (LinearLayout) inflater.inflate(R.layout.recycler_view_layout, null, false);

RecyclerView recyclerView = (RecyclerView) layout.findViewById(R.id.recyclerView);
LinearLayoutManager layoutManager = new LinearLayoutManager(context, LinearLayoutManager.HORIZONTAL, false);

recyclerView.setHasFixedSize(false);
recyclerView.setLayoutManager(layoutManager);
recyclerView.setAdapter(this);
recyclerView.setItemAnimator(new DefaultItemAnimator());
recyclerView.setNestedScrollingEnabled(false);

「速度」の NestedScrollView を変更しようとしましたが、適切なアドバイスや投稿が見つかりません。適切なアドバイスや投稿が見つからない可能性があります。誰かが助けることができますか?

4

1 に答える 1

0

これらのライブラリのいずれかを実装する必要があると思います (GitHub でさらに見つけることができます)。


Androidの標準ライブラリでRecyclerViewやりたい場合、横スクロールしたい場合に便利かもしれません

水平スクロールがサポートされていることを証明するには、次をご覧ください。

public boolean canScrollHorizo​​ntally ()

水平スクロールが現在サポートされているかどうかを問い合わせます。デフォルトの実装は false を返します。

この LayoutManager が現在のコンテンツを水平方向にスクロールできる場合は True を返します

また

public int computeHorizo​​ntalScrollExtent (RecyclerView.State 状態)

スクロール バーをサポートする場合は、このメソッドをオーバーライドします。

詳細については、computeHorizo​​ntalScrollExtent() を参照してください。

デフォルトの実装は 0 を返します。

から: https://developer.android.com/reference/android/support/v7/widget/RecyclerView.LayoutManager.html

RecyclerView呼び出されたサブクラスもチェックHorizontalGridView

それが役立つことを願っています。

于 2016-01-04T21:34:30.160 に答える