2017-03-13 37 views
1
<ScrollView 
    android:layout_width="match_parent" 
    android:layout_height="match_parent"> 

    <HorizontalScrollView 
     android:layout_width="match_parent" 
     android:layout_height="wrap_content"> 

     <TextView 
      android:id="@+id/solutions" 
      android:layout_width="wrap_content" 
      android:layout_height="wrap_content" 
      android:lineSpacingMultiplier="1.2" 
      android:textAppearance="@style/TextAppearance.AppCompat" 
      android:textIsSelectable="true" 
      android:textSize="18sp" 
      tools:text="1. 1+2+3 = 6"/> 
    </HorizontalScrollView> 
</ScrollView> 

添加android:textIsSelectable="true"TextView后,TextView将自动滚动至底部。但是我不想要这种行为。添加机器人:textIsSelectable导致的TextView到自动滚动

回答

0

试试这个:添加

android:focusable="false" 
android:focusableInTouchMode="false" 

<TextView 
     android:id="@+id/solutions" 
     android:layout_width="wrap_content" 
     android:layout_height="wrap_content" 
     android:focusable="false" 
     android:focusableInTouchMode="false" 
     android:lineSpacingMultiplier="1.2" 
     android:text="1. 1+2+3 = 6" 
     android:textAppearance="@style/TextAppearance.AppCompat" 
     android:textIsSelectable="true" 
     android:textSize="18sp" /> 

解决方案的原因是:

当您使用android:textIsSelectable="true",你基本上调用TextView.setTextIsSelectable(true),这使得双方View.setFocusableView.setFocusableInTouchMode.电话...和导致scrollview自动滚动文本。

+1

这使得文本无法选择 – Andre

+0

请您告诉我们更多关于您的想法。 –

+0

虽然此代码可能会回答问题,但提供其他关于_how_和/或_why_的[上下文](https://meta.stackexchange.com/q/114762)可以解决问题,从而提高答案的长期价值。请记住,你正在为将来的读者回答这个问题,而不仅仅是现在问的人!请[编辑](http://stackoverflow.com/posts/42761382/edit)您的答案添加一个解释,并指出适用的限制和假设。 –