Frage

Ich habe ein RelativeLayout in meiner App, aber wenn sich das Telefon im Querformat befindet, scrollt es nicht.Ich habe gelesen, dass ich es in eine ScrollView einfügen muss, erhalte aber ständig Fehlermeldungen, sodass ich es möglicherweise nicht richtig mache.

Irgendwelche Tipps?

Dank im Voraus.

<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="#ff8400"
android:orientation="vertical" >

<EditText
    android:id="@+id/txt_nomeSpot"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:layout_alignParentTop="true"
    android:layout_centerHorizontal="true"
    android:layout_marginTop="42dp"
    android:ems="10"
    android:hint="@string/nome"
    android:inputType="text" 
    android:gravity="center" >

    <requestFocus />
</EditText>

<EditText
    android:id="@+id/txt_coordSpot"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:layout_below="@+id/txt_nomeSpot"
    android:layout_centerHorizontal="true"
    android:layout_marginTop="20dp"
    android:hint="@string/coordenadas"
    android:inputType="text" 
    android:ems="10"
    android:gravity="center" />

<EditText
    android:id="@+id/txt_classSpot"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:layout_below="@+id/txt_coordSpot"
    android:layout_centerHorizontal="true"
    android:layout_marginTop="20dp"
    android:hint="@string/classif"
    android:inputType="text" 
    android:ems="10"
    android:gravity="center" />

<EditText
    android:id="@+id/txt_tipoSpot"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:layout_below="@+id/txt_classSpot"
    android:layout_centerHorizontal="true"
    android:layout_marginTop="20dp"
    android:hint="@string/tipo"
    android:inputType="text" 
    android:ems="10" 
    android:gravity="center"/>

<EditText
    android:id="@+id/txt_subtipoSpot"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:layout_below="@+id/txt_tipoSpot"
    android:layout_centerHorizontal="true"
    android:layout_marginTop="20dp"
    android:hint="@string/subtipo"
    android:inputType="text" 
    android:ems="10"
    android:gravity="center" />

<EditText
    android:id="@+id/txt_moradaSpot"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:layout_below="@+id/txt_subtipoSpot"
    android:layout_centerHorizontal="true"
    android:layout_marginTop="20dp"
    android:hint="@string/morada"
    android:inputType="text" 
    android:ems="10"
    android:gravity="center" />

<Button
    android:id="@+id/btn_submitSpot"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:layout_below="@+id/txt_moradaSpot"
    android:layout_centerHorizontal="true"
    android:layout_marginTop="20dp"
    android:text="@string/submeter" />

War es hilfreich?

Lösung

Habe einfach den ScrollView als Top-Level-Element.Ihr vorhandenes Relativivelayout geht dann hinein.

generasacodicetagpre.

edit: Ich habe die Höhe Ihres Relativivelayouts in "wrap_content" geändert, da Kabuko korrekt ist, was er in seiner Antwort sagt.

Andere Tipps

Du brauchst ein ScrollView, aber es macht keinen Sinn für die View innen hoch sein match_parent.Das würde das Innere machen View die gleiche Größe wie die ScrollView Es bleibt nichts zum Scrollen übrig.Sie müssen das Innere einstellen View (in diesem Fall Ihr RelativeLayout) groß genug, um den gesamten Inhalt anzuzeigen.Im Allgemeinen bedeutet das wrap_content.

Lizenziert unter: CC-BY-SA mit Zuschreibung
Nicht verbunden mit StackOverflow
scroll top