0

RecyclerView(画面A)内にあり、FrameLayout(画面B)の内部にあります。Android:TextView内のテキストは、LinearLayoutではスクロールされますが、Recyclerviewではスクロールされません。

RecyclerViewでは、textviewは10行だけをレンダリングし、追加のテキストは無視されます。

LinearLayoutのテキストビューは10行を表示しますが、ユーザーはスクロールすることができます。

スクロールを無効にして、maxLinesを使用して設定した最大行を表示する方法。

私はすでに、

  • android:isScrollContainer="false"を試してみました - それは

  • android:enabled="false"を動作しません - それは

のTextViewでハイパーリンクのクリックを無効にする更新日:

RecyclerViewのtextviewをスクロールしたくないので、LinearLayoutでスクロールを無効にしたい。

+0

スクロールを無効にするxmlをここに追加します。 – ADM

答えて

1

次の行を試しましたか?

recyclerView.setNestedScrollingEnabled(false); 
1

NoScrollTextViewは、このようなTextViewを拡張して作成します。

public class NoScrollTextView extends TextView { 
    public NoScrollTextView(Context context) { 
     super(context); 
    } 

    public NoScrollTextView(Context context, AttributeSet attrs) { 
     super(context, attrs); 
    } 

    public NoScrollTextView(Context context, AttributeSet attrs, int defStyleAttr) { 
     super(context, attrs, defStyleAttr); 
    } 

    @TargetApi(Build.VERSION_CODES.LOLLIPOP) 
    public NoScrollTextView(Context context, AttributeSet attrs, int defStyleAttr, int defStyleRes) { 
     super(context, attrs, defStyleAttr, defStyleRes); 
    } 

    @Override 
    public void scrollTo(int x, int y) { 
     //do nothing 
    } 
} 

次にとしてXMLでこれを使用します。

だけ

TextView tv = (TextView) view.findViewById(R.id.tv); 
    tv.setMovementMethod(null); 

やレイアウトにクラスに設定

<com.example.NoScrollTextView 
     android:layout_width="match_parent" 
     android:layout_height="wrap_content" 
     android:maxLines="10"/> 
+0

そうですね、これを試してみましたが、カスタムビューを作成するのではなく、ビューのプロパティを変更または設定するだけで、より良いアプローチを探しています。 –

+1

貼り付けてはいけません同じ回答はこちらですhttps://stackoverflow.com/questions/24027108/how-do-i-completely-prevent-a-textview-from-scrolling –

+1

私はそれを変更しました。 –

1

   <TextView 
       android:id="@+id/tv" 
       android:layout_width="wrap_content" 
       android:layout_height="wrap_content" 
       android:layout_marginTop="3dp" 
       android:maxLines="8" 
       android:text="Lorem Ipsum is simply dummy text of the dummy text of t printing and typesetting industry. Lorem Ipsum has been the industry's standard dummy." 
       android:textSize="14sp" /> 
+0

downvoteの理由を説明してください? –

関連する問題