Jorge Leonardo
Jorge Leonardo

Reputation: 163

How can I make my design adapt to portrait and landscape orientation?

How can I make my design adapt to landscape orientation.

in portrait orientation, I designed it like this:

enter image description here

In landscape orientation it looks like this:

enter image description here

This is my code

<Button
    android:id="@+id/bt_ingresar"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:layout_marginTop="36dp"
    android:text="@string/ingresar_usuario"
    app:layout_constraintEnd_toEndOf="parent"
    app:layout_constraintHorizontal_bias="0.498"
    app:layout_constraintStart_toStartOf="parent"
    app:layout_constraintTop_toBottomOf="@+id/et_clave" />

<Button
    android:id="@+id/bt_registrar"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:layout_marginTop="36dp"
    android:text="@string/registrar_usuario"
    app:layout_constraintEnd_toEndOf="parent"
    app:layout_constraintHorizontal_bias="0.498"
    app:layout_constraintStart_toStartOf="parent"
    app:layout_constraintTop_toBottomOf="@+id/bt_ingresar" />

Upvotes: 0

Views: 126

Answers (1)

Muntasir Aonik
Muntasir Aonik

Reputation: 1957

I think the case is your screen is simply not large enough to show the whole content. Android does not add the scroll functionality if the content is larger then the screen. If this is the case wrap all your views in a ScrollView so that the buttons could be visible after scrolling. Like this:

<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
          xmlns:tools="http://schemas.android.com/tools"
          android:orientation="vertical"
          android:layout_width="match_parent"
          android:layout_height="match_parent"
          android:padding="4dp"> 

    <ScrollView
        android:layout_width="match_parent"
        android:layout_height="match_parent">

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

            <!-- Putt all your view here -->

        </LinearLayout>
    </ScrollView>
</LinearLayout>

Upvotes: 1

Related Questions