Layout does not fit on screen after rotation

2

I developed an application that works normally but when I turn the screen to the landscape orientation the app gets cut off and I can not go down and see the rest of the content and also the AdMob I implemented only works on the screen vertical, horizontal does not display ads, what can it be?

Vertical:

Horizontal:

    
asked by anonymous 17.08.2016 / 22:51

2 answers

5

One way to solve your problem is to insert your content into a Scrollview , respectively allows the vertical scroll bar. And another way for you to solve is Exploring Smartphone Guidance.

1. ScrollView

<?xml version="1.0" encoding="utf-8"?>
<ScrollView xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="wrap_content">

    <LinearLayout 
        android:id="@+id/layout1"
        android:layout_width="fill_parent"
        android:layout_height="wrap_content"
        android:orientation="vertical">

        <!-- 
         Aqui será exibia nossa lista
         -->

    </LinearLayout>
</ScrollView>

To get another idea, note the image below the ScrollView and HorizontalScrollView schema:

This link has a very easy example to help you make that.

2. Exploring Guidance

As suggested in the comments, you can create two different layouts according to the orientation of your smartphone.

res/
    layout/              # default (portrait)
        main.xml
    layout-land/         # landscape
        main.xml
    layout-large/        # large (portrait)
        main.xml
    layout-large-land/   # large landscape
        main.xml

ReadtheAndroiddocumentationon Supporting Different Screens you will get more notion.

    
17.08.2016 / 22:57
0

You can create two layout or use scrool view as below!

 <?xml version="1.0" encoding="utf-8"?>
 <RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:paddingBottom="@dimen/activity_vertical_margin"
android:paddingLeft="@dimen/activity_horizontal_margin"
android:paddingRight="@dimen/activity_horizontal_margin"
android:paddingTop="@dimen/activity_vertical_margin"
app:layout_behavior="@string/appbar_scrolling_view_behavior">

<ScrollView android:layout_width="fill_parent"
    android:layout_height="fill_parent"
    android:id="@+id/scrollView"
    android:layout_marginTop="40dp">

    <LinearLayout
        android:orientation="vertical"
        android:layout_width="match_parent"
        android:weightSum="1"
        android:layout_height="match_parent"
        android:layout_alignParentTop="true"
        android:layout_alignParentLeft="true"
        android:layout_alignParentStart="true">

        <ImageView
            android:layout_width="match_parent"
            android:layout_height="150px"
            android:src="@drawable/ico_login"
            android:layout_marginTop="100px"
            />

        <EditText
            android:layout_width="fill_parent"
            android:layout_height="90px"
            android:id="@+id/edtEmailLogin"
            android:hint="@string/emailUsuario"
            android:drawableLeft="@android:drawable/ic_dialog_email"
            android:textAlignment="center"
            android:layout_marginBottom="15dp"
            />

        <EditText
            android:layout_width="fill_parent"
            android:layout_height="90px"
            android:inputType="textPassword"
            android:id="@+id/edtSenhaLogin"
            android:hint="@string/senhaUsuario"
            android:drawableLeft="@android:drawable/ic_lock_idle_lock"
            android:textAlignment="center"
            android:layout_marginBottom="15dp"

            />

        <LinearLayout
            android:orientation="horizontal"
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:weightSum="1"
            android:baselineAligned="false"
            android:layout_marginBottom="15dp"
            android:gravity="center">

            <Button
                android:layout_width="143dp"
                android:layout_height="wrap_content"
                android:id="@+id/btnEntrar"
                android:text="@string/botaoEnviar"
                android:onClick="setContentView"

                />

            <Button
                android:layout_width="143dp"
                android:layout_height="wrap_content"
                android:id="@+id/btnCancelar"
                android:text="@string/botaoCancelar"
                android:onClick="setContentView"
                android:layout_weight="0.27"

                />

        </LinearLayout>

    </LinearLayout>
</ScrollView>

    
25.08.2016 / 20:15