I'm trying to create an android app with RelativeLayout inside a scroll view which has a TextView with scrollbar but every time I try to scroll the TextView, RelativeLayout gets scrolled.
I've also tried following solutions but nothing works:
https://www.viralandroid.com/2015/10/how-to-make-scrollable-textview-in-android.html
how to make a relative layout scrollable when it has many children views?
*My layout looks almost similar to 3rd link but with more controls.
Following is the code for my layout
<?xml version="1.0" encoding="utf-8"?>
<ScrollView xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/ScrollView01"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:scrollbars="vertical">
<RelativeLayout 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=".MainActivity"
android:scrollbars = "vertical">
<TextView
android:id="@+id/textView1"
android:layout_width="365dp"
android:layout_height="20dp"
android:layout_alignParentStart="true"
android:layout_alignParentTop="true"
android:layout_marginStart="10dp"
android:layout_marginTop="5dp"
android:layout_marginEnd="5dp"
android:text="@string/text1" />
<EditText
android:id="@+id/editText1"
android:layout_width="365dp"
android:layout_height="40dp"
android:layout_below="@+id/textView1"
android:layout_alignParentStart="true"
android:layout_marginStart="10dp"
android:layout_marginEnd="5dp"
android:inputType="text"
android:text=""/>
<!-- Other Controls, about 15 of them -->
<TextView
android:id="@+id/testLogs"
android:layout_width="360dp"
android:layout_height="150dp"
android:layout_below="@+id/something"
android:layout_alignParentStart="true"
android:layout_marginStart="14dp"
android:layout_marginTop="15dp"
android:layout_marginEnd="14dp"
android:background="@drawable/edit_text_background"
android:textColor="@color/editTestBorderColor"
android:enabled="true"
android:gravity="bottom"
android:hint="Process logs"
android:scrollbars="vertical"
android:textIsSelectable="true"
android:focusable="true"
android:longClickable="true"
android:textSize="10dp" />
<Button
android:id="@+id/btnExecuteTest"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="@+id/editTextLogs"
android:layout_alignParentStart="true"
android:layout_marginStart="67dp"
android:layout_marginTop="10dp"
android:text="@string/btnExecute" />
</RelativeLayout>
</ScrollView>
Problem : Unable to scroll Textview (android:id="@+id/testLogs")
Somehow if I have less controls(as long as layout's scrollable is not activated) then TextView's scroll is working.
Following are the device specs. that I'm using for testing :
- Name : Huawei P10 lite
- OS : Android 8.0
I have no idea why TextView scroll si not working? Help Please!