2016-01-09 3 views
0

У меня проблема в моем приложении.Режим Android Landscape отключил мой последний EditText

Мой макет содержит:

  • ImageView
  • Кнопка
  • Четыре EditText

Когда я изменяю эмулятор в режиме пейзажа ScrollView идет к третьему EditText. Последний EditText не отображается в альбомном режиме.

Мой layout.xml

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

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

    <RelativeLayout 
     android:layout_width="wrap_content" 
     android:layout_height="235dp"> 

     <ImageView 
      android:layout_width="match_parent" 
      android:layout_height="200dp" 
      android:id="@+id/formulario_foto" 
      android:background="#00A8EC" 
      android:src="@drawable/person"/> 

     <Button 
      android:layout_width="56dp" 
      android:layout_height="56dp" 
      android:id="@+id/formulario_foto_button" 
      android:layout_alignParentBottom='true' 
      android:layout_alignParentRight="true" 
      android:layout_marginBottom="5dp" 
      android:layout_marginRight="20dp" 
      android:background="@drawable/formulario_foto_button" 
      android:elevation="5dp" 
      android:gravity="center" 
      android:textColor="#FFFFFF" 
      android:textSize="20sp"/> 

    </RelativeLayout> 

    <EditText 
     android:layout_width="match_parent" 
     android:layout_height="wrap_content" 
     android:layout_marginBottom="10dp" 
     android:hint="Nome" 
     android:id="@+id/editTextNome" /> 

    <EditText 
     android:layout_width="match_parent" 
     android:layout_height="wrap_content" 
     android:layout_marginBottom="10dp" 
     android:ems="10" 
     android:hint="E-mail" 
     android:id="@+id/editTextEmail" /> 

    <EditText 
     android:layout_width="match_parent" 
     android:layout_height="wrap_content" 
     android:layout_marginBottom="10dp" 
     android:hint="Endereço" 
     android:id="@+id/editTextEndereco" /> 

    <EditText 
     android:layout_width="match_parent" 
     android:layout_height="wrap_content" 
     android:layout_marginBottom="10dp" 
     android:inputType="phone" 
     android:ems="10" 
     android:hint="Telefone" 
     android:id="@+id/editTextTelefone" /> 

    </LinearLayout> 
</ScrollView> 
+0

Вы определили свою относительную высоту размещения 235 дп, но общая высота его ребенка составляет 256 дп ?? –

ответ

2

Похоже ScrollView не уважает запас своего ребенка. Такое поведение было отмечено в

Чтобы обойти эту проблему, чтобы обернуть ваш LinearLayout в FrameLayout, то есть.

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

    <LinearLayout 
     android:layout_width="match_parent" 
     android:layout_height="match_parent" 
     android:layout_marginTop="60dp" 
     android:orientation="vertical"> 
    ... 
    </LinearLayout> 
</FrameLayout> 

Это немного неэффективно, так как он использует дополнительный ViewGroup. Если вы в состоянии это сделать, более эффективным решением будет использование paddingTop на LinearLayout вместо layout_marginTop, т.е.

<LinearLayout 
    android:layout_width="match_parent" 
    android:layout_height="match_parent" 
    android:paddingTop="60dp" 
    android:orientation="vertical"> 
... 
</LinearLayout> 
+0

Отлично! Tks !!! –

0

Изменение линейной высота макет wrap_content

+0

Я внес изменения, но та же проблема продолжается = [ –