How do you spell out the elements so they don't go outside the screen?



  • Hello. Before launching, the annex is as follows: введите сюда описание изображения

    It's like the height buttons are equal. But after the launch, the app looks like: введите сюда описание изображения

    As you can see, the last element exits the screen or its height has diminished. Button-ov are no longer equal. Why is this happening? What do you have to do that doesn't happen? Here's the xml code:

    <?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">
    

    <TextView
    android:text="Вопрос"
    android:gravity="center"
    android:layout_width="match_parent"
    android:layout_height="185dp"
    android:textColor="#fff"
    android:id="@+id/QuestionText"
    android:background="#000000"
    android:textSize="20dp" />

    <LinearLayout
    android:orientation="horizontal"
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    android:background="#000000"
    >

    &lt;Button
        android:text="Предыдущий"
        android:layout_width="0dp"
        android:layout_weight="1"
        android:layout_height="match_parent"
    
        android:textColor="#000"
        android:background="#fff" /&gt;
    
    &lt;Button
        android:text="Следующий"
        android:layout_width="0dp"
        android:layout_weight="1"
        android:layout_height="match_parent"
    
        android:textColor="#000"
        android:background="#fff"
        android:id="@+id/nextButton"
        android:onClick="ShowNextQuestion"
        /&gt;
    

    </LinearLayout>

    <LinearLayout
    android:orientation="vertical"
    android:layout_width="match_parent"
    android:layout_height="wrap_content"

    &gt;
    
    &lt;Button
        android:text="Ответ А"
        android:layout_width="match_parent"
        android:layout_weight="1"
        android:layout_height="70dp"
        android:textColor="#000000"
        android:onClick="OptionButtonPressed"
        android:id="@+id/opta"
        android:background="#fff" /&gt;
    
    &lt;Button
        android:text="Ответ В"
        android:layout_width="match_parent"
        android:layout_weight="1"
        android:layout_height="70dp"
        android:textColor="#000000"
        android:background="#fff"
        android:id="@+id/optb"
        android:onClick="OptionButtonPressed"
        /&gt;
    

    </LinearLayout>

    <LinearLayout
    android:orientation="vertical"
    android:layout_width="match_parent"
    android:layout_height="wrap_content">

    &lt;Button
        android:text="Ответ С"
        android:background="#fff"
        android:layout_width="match_parent"
        android:layout_weight="1"
        android:layout_height="70dp"
        android:onClick="OptionButtonPressed"
        android:id="@+id/optc" /&gt;
    
    &lt;Button
        android:text="Ответ D"
        android:background="#fff"
        android:layout_width="match_parent"
        android:layout_weight="1"
        android:layout_height="70dp"
        android:textColor="#000000"
        android:onClick="OptionButtonPressed"
        android:id="@+id/optd" /&gt;
    

    </LinearLayout>



  • Use the relative RelativeLayout. Thus, the dynamic dimensions of all components can be applied and located - some below the screen, others above them. Some up the screen, some underneath them.

    In your current case, the general space is not sufficient to accommodate all the assigned elements, as they have clear dimensions, for example.

    70dp
    



Suggested Topics

  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2