I am going to make an application for different screens. As I read, you should avoid using certain numerical values for height and width.
Problem: I have a TextView within which the amount of text changes.
In order not to use numerical values for the height of this TextView , I set layout_height="wrap_content" , but the fact is that from the bottom of this TextView there are as many as 5 Button s, and their position depends on TextView :
If the TextView has a small height, then these Button s seek up, and a lot of space remains at the bottom of the screen (picture1). This means that the TextView should be fairly high, so that these Button s, roughly speaking, stuck to the end of the screen.
In the photo, the TextView (question) has a height of 210dp , but since setting the value is not desirable, an idea appeared to put all the Button-ы at the bottom of the screen, then put the TextView Вопрос over the entire space between the TextView Question Counter and Button '>'(next) .
But how can this be done? Is this solution appropriate?
Please tell me how to solve the problem. Below is the xml code and screenshots:
<?xml version="1.0" encoding="utf-8"?> <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" android:orientation="vertical" android:layout_width="match_parent" android:layout_height="match_parent" android:background="#000000"> <TextView android:layout_width="match_parent" android:gravity="center" android:layout_height="wrap_content" android:textSize="22dp" android:text="Quest Counter" android:id="@+id/questCounterId" android:textColor="#FFFFFF" /> <TextView android:text="Вопрос" android:gravity="center" android:layout_width="match_parent" android:layout_height="wrap_content" android:textColor="#fff" android:id="@+id/QuestionText" android:background="#000000" android:textSize="24dp" /> <Button android:layout_gravity="center" android:text=">" android:layout_width="wrap_content" android:layout_height="wrap_content" android:id="@+id/nextButton" android:onClick="ShowNextQuestion" android:background="@drawable/using_nextprevbuttons" android:shadowColor="#FFFFFF" android:shadowDx="0" android:shadowDy="0" android:shadowRadius="4" android:layout_marginBottom="10dp" android:textSize="32dp"/> <LinearLayout android:orientation="horizontal" android:layout_width="match_parent" android:layout_height="wrap_content" android:layout_marginBottom="10dp" > <Button android:onClick="OptionButtonPressed" android:id="@+id/opta" android:text="Ответ А" android:layout_width="0dp" android:layout_weight="1" android:layout_height="wrap_content" android:background="@drawable/using_optionshape" android:textColor="#000000" android:shadowColor="#FFFFFF" android:shadowDx="0" android:shadowDy="0" android:shadowRadius="5" android:layout_marginRight="10dp" android:layout_marginLeft="5dp"/> <Button android:id="@+id/optb" android:onClick="OptionButtonPressed" android:text="Ответ В" android:layout_width="0dp" android:layout_weight="1" android:layout_height="wrap_content" android:background="@drawable/using_optionshape" android:textColor="#000000" android:shadowColor="#FFFFFF" android:shadowDx="0" android:shadowDy="0" android:shadowRadius="5" android:layout_marginRight="5dp"/> </LinearLayout> <LinearLayout android:orientation="horizontal" android:layout_width="match_parent" android:layout_height="wrap_content"> <Button android:text="Ответ С" android:layout_width="0dp" android:layout_weight="1" android:layout_height="match_parent" android:background="@drawable/using_optionshape" android:textColor="#000000" android:shadowColor="#FFFFFF" android:shadowDx="0" android:shadowDy="0" android:shadowRadius="5" android:layout_marginRight="10dp" android:layout_marginLeft="5dp" android:onClick="OptionButtonPressed" android:id="@+id/optc" /> <Button android:text="Ответ D" android:layout_width="0dp" android:layout_weight="1" android:layout_height="match_parent" android:background="@drawable/using_optionshape" android:textColor="#000000" android:shadowColor="#FFFFFF" android:shadowDx="0" android:shadowDy="0" android:shadowRadius="5" android:layout_marginRight="5dp" android:id="@+id/optd" android:onClick="OptionButtonPressed"/> </LinearLayout> </LinearLayout> 

Вопросwas in the middle, and the buttons were pressed to the bottom? - post_zeew