In the layout there are several vertically positioned TextView, but only one is displayed, the top one.

What is wrong, how to fix?

<?xml version="1.0" encoding="utf-8"?> <LinearLayout 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" android:background="#dcd8c8" android:orientation="vertical"> <TextView android:layout_width="match_parent" android:layout_height="match_parent" android:id="@+id/txt91" android:textColor="#000000" android:text="Глава №1" android:textSize="24sp" android:textStyle="bold" /> <ScrollView android:layout_width="match_parent" android:layout_height="match_parent" android:layout_marginTop="100dp"> <TextView android:id="@+id/txt92" android:layout_width="match_parent" android:layout_height="match_parent" android:textColor="#000000" android:textSize="18sp" android:text="@string/text103"/> </ScrollView> </LinearLayout> 
  • Why did you put the second TextView in ScrollView? - Werder
  • so that the text scrolled, and what is wrong? - mtb
  • I understand that my problem is that I need to specify wrap_content in the first textview - mtb
  • Yes, you specified the first TextView to occupy the entire area of ​​the container ( LinearLayout ) in which it is nested (the height and width of the match_parent ) - it occupies it, the rest is empty , - pavlofff

1 answer 1

 android:layout_height="match_parent" 

change to

 android:layout_height="wrap_content" 

or some value in dp . The first element you have is stretched to full screen and the rest, respectively, is already compressed to 0.