<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" android:orientation="vertical" android:layout_centerInParent="true" tools:context="com.example.asus.hackaton.view.examview.remindersview.RemindersFragment"> <LinearLayout android:layout_width="wrap_content" android:layout_centerInParent="true" android:orientation="vertical" android:layout_height="wrap_content"> <LinearLayout android:layout_width="wrap_content" android:orientation="horizontal" android:layout_height="wrap_content"> <TextView android:layout_width="wrap_content" android:layout_height="wrap_content" android:id="@+id/text_view_morning" android:layout_marginRight="6dp" android:text="Утро " /> <Button android:id="@+id/button_morning_time" style="@style/Widget.AppCompat.Button.Colored" android:layout_width="wrap_content" android:layout_height="wrap_content" android:text="Введите" android:textStyle="bold" /> </LinearLayout> <LinearLayout android:layout_width="wrap_content" android:orientation="horizontal" android:layout_height="wrap_content"> <TextView android:layout_width="wrap_content" android:layout_height="wrap_content" android:id="@+id/text_view_evening" android:text="Вечер "/> <Button android:id="@+id/button_evening_time" style="@style/Widget.AppCompat.Button.Colored" android:layout_width="wrap_content" android:layout_height="wrap_content" android:text="Введите" android:textStyle="bold" /> </LinearLayout> <Button android:layout_width="wrap_content" android:text="Сохранить" android:id="@+id/save_button" android:textStyle="bold" android:layout_height="wrap_content" style="@style/Widget.AppCompat.Button.Colored" /> </LinearLayout> </RelativeLayout> 

How to save the button "save_button" to full screen?

    2 answers 2

    Just like any other view - setting its width to the entire parent container - match_parent

    In your case, the button for this must be taken out of the current parent, which does not allow it to expand, for it itself has a width in content. At the same time, to save the position, you must set the current parent ID and specify the button to be at the bottom of the current parent via the android:layout_below attribute android:layout_below

    • This is a really great answer, but by setting match_parent it doesn't stretch to full screen in this case) - Martinez Toni
    • @MartinezToni, this is because it lies in LinearLayout, which is wide in content. Move the button out of its current parent - YuriySPb
    • Then the button will shift to an unnecessary position. - Martinez Toni
    • @MartinezToni, yes, if you do not tell her to be under her current parent. To do this, set the ID to this, and specify layoutBelow or layoutAbove - Yuriy SPb
    • Indicate this in the answer. And the question will be closed. - Martinez Toni

    The widget can be stretched (in width or in height) only within the parent container.

    By setting the attribute android:layout_width="match_parent" the save_button button, save_button can stretch this button to the width of the parent ViewGroup , in this case, to the width of the LinearLayout .

    Since the parent ViewGroup for this button has the android:layout_width="wrap_content" , the button will not be stretched across the width of the entire screen.

    To stretch a button to the width of the entire screen, you need to set the android:layout_width="match_parent" for the parent save_button button ViewGroup - LinearLayout .