لن يتم تمرير Android RelativeLayout عندما يكون في الوضع الأفقي
-
22-12-2019 - |
سؤال
لدي RelativeLayout في تطبيقي، ولكن عندما يكون الهاتف في الوضع الأفقي، فلن يتم التمرير.قرأت أنني بحاجة إلى وضعه داخل ScrollView ولكنني أتلقى أخطاء باستمرار، لذلك ربما لا أفعل ذلك بشكل صحيح.
أي نصائح؟
شكرا لك مقدما.
<?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" />
المحلول
لديها ببساطة التمرير كعنصر المستوى الأعلى.retrativelayout الحالي الخاص بك ثم يذهب في الداخل.
giveacodicetagpre.تحرير: لقد غيرت ارتفاع relativelayout الخاص بك إلى "Wrap_Content" منذ كابوكو صحيحة بما يقول في إجابته.
نصائح أخرى
أنت بحاجة إلى ScrollView
, ، ولكن هذا ليس له معنى بالنسبة ل View
داخل ليكون الارتفاع match_parent
.وهذا من شأنه أن يجعل الداخل View
نفس حجم ScrollView
لا تترك شيئا للتمرير.تحتاج إلى ضبط الداخلية View
(في هذه الحالة الخاص بك RelativeLayout
) طويل بما يكفي لإظهار كل محتوياته.عموماً يعني wrap_content
.
لا تنتمي إلى StackOverflow