I'd like to make a TextView scrollable when the maxLines is >= to 10. I tried this code:
<LinearLayout
android:id="@+id/powers_layout"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginBottom="16dp"
android:orientation="vertical">
<TextView
android:id="@+id/powers"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:maxLines="10"
android:scrollbars="vertical"
android:paddingLeft="@dimen/activity_horizontal_margin"
android:paddingRight="@dimen/activity_horizontal_margin"
android:text="Powers"
android:textSize="@dimen/primary_text_size"/>
</LinearLayout>
with this:
TextView textPowers = (TextView) findViewById(R.id.powers);
textPowers.setMovementMethod(new ScrollingMovementMethod());
I can see the scroll bar but the TextView doesn't scroll correctly. I also tried to use a ScrollView without success. The only way I found to run it is to set the ScrollView height like this:
<android.support.v4.widget.NestedScrollView
android:id="@+id/scroll_powers"
android:layout_width="match_parent"
android:layout_height="180dp">
<TextView
android:id="@+id/powers"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:paddingLeft="@dimen/activity_horizontal_margin"
android:paddingRight="@dimen/activity_horizontal_margin"
android:scrollbars="vertical"
android:text="Powers"
android:textSize="@dimen/primary_text_size"/>
</android.support.v4.widget.NestedScrollView>
but in this case I would continue to have an height of 180dp even when the lines are less than 10. What can I do? I've read many problems like this on stackoverflow like: Making TextView scrollable on Android but without success.