在Android中滚动旋转视图

时间:2015-04-19 21:12:35

标签: android scroll rotation relativelayout

我正在编写Android应用程序。

我有一些带有一些EditTexts,一个微调器和一些按钮的活动。按钮位于布局的底部。 当我旋转模拟器时,底部的按钮在横向旋转时会从屏幕底部旋转,因为它不是那么高。是否可以在视图滚动时使其滚动,因此我可以到达按钮。 (我使用的是相对布局)。

感谢您的帮助。

1 个答案:

答案 0 :(得分:1)

是的,有可能......使用scrollview,每件事都会如你所愿 试试这个..我猜它会有所帮助

<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:tools="http://schemas.android.com/tools" android:layout_width="fill_parent"
    android:layout_height="fill_parent"
    android:background="@drawable/layout_back"
    tools:context="eddine.charef.mechalikh.swipedemo.inscription" >

    <ScrollView
        android:layout_width="fill_parent"
        android:layout_height="fill_parent"
        android:id="@+id/scrollView3"
        android:layout_above="@+id/textView2"  >
        <LinearLayout
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:paddingLeft="@dimen/activity_horizontal_margin"
            android:paddingRight="@dimen/activity_horizontal_margin"
            android:paddingTop="@dimen/activity_vertical_margin"
            android:paddingBottom="@dimen/activity_vertical_margin"
            android:orientation="vertical"
            android:weightSum="1"
            android:layout_alignParentTop="true"
            android:layout_alignParentLeft="true"
            android:layout_alignParentStart="true">

            <TextView
                android:layout_width="match_parent"
                android:layout_height="wrap_content"
                android:textAppearance="?android:attr/textAppearanceMedium"
                android:text="@string/infosGenerales"
                android:id="@+id/textView5"
                android:background="#0061C2"
                android:textColor="#ffffffff" />

            <EditText
                android:layout_width="match_parent"
                android:layout_height="wrap_content"
                android:inputType="textPersonName"
                android:ems="10"
                android:id="@+id/editNom"
                android:layout_weight="0.15"
                android:hint="@string/nom"
                android:gravity="center"
                android:background="@drawable/rounded_corner_2"
                android:layout_marginTop="10dp"
                android:layout_marginBottom="5dp"
                android:selectAllOnFocus="false"
                android:paddingTop="5dp"
                android:paddingBottom="5dp" />

            <EditText
                android:layout_width="match_parent"
                android:layout_height="wrap_content"
                android:inputType="textPersonName"
                android:ems="10"
                android:id="@+id/editPrenom"
                android:layout_weight="0.15"
                android:hint="@string/prenom"
                android:gravity="center"
                android:background="@drawable/rounded_corner_2"
                android:layout_marginTop="5dp"
                android:layout_marginBottom="5dp"
                android:selectAllOnFocus="false"
                android:paddingTop="5dp"
                android:paddingBottom="5dp" />

            <EditText
                android:layout_width="match_parent"
                android:layout_height="wrap_content"
                android:inputType="textEmailAddress"
                android:ems="10"
                android:id="@+id/editEmail"
                android:layout_weight="0.15"
                android:hint="@string/email"
                android:gravity="center"
                android:background="@drawable/rounded_corner_2"
                android:layout_marginTop="5dp"
                android:layout_marginBottom="5dp"
                android:selectAllOnFocus="false"
                android:paddingTop="5dp"
                android:paddingBottom="5dp" />

            <EditText
                android:layout_width="match_parent"
                android:layout_height="wrap_content"
                android:inputType="textPassword"
                android:ems="10"
                android:id="@+id/editPswrd"
                android:layout_weight="0.15"
                android:hint="@string/mdp"
                android:gravity="center"
                android:background="@drawable/rounded_corner_2"
                android:layout_marginTop="5dp"
                android:layout_marginBottom="5dp"
                android:selectAllOnFocus="false"
                android:paddingTop="5dp"
                android:paddingBottom="5dp" />

            <EditText
                android:layout_width="match_parent"
                android:layout_height="wrap_content"
                android:inputType="textPassword"
                android:ems="10"
                android:id="@+id/editCnfrmPswrd"
                android:layout_weight="0.15"
                android:hint="@string/retapezMdp"
                android:gravity="center"
                android:background="@drawable/rounded_corner_2"
                android:layout_marginTop="5dp"
                android:layout_marginBottom="5dp"
                android:selectAllOnFocus="false"
                android:paddingTop="5dp"
                android:paddingBottom="5dp" />

            <Spinner
                android:layout_width="match_parent"
                android:layout_height="wrap_content"
                android:id="@+id/spinner4" />

            <TextView
                android:layout_width="match_parent"
                android:layout_height="wrap_content"
                android:textAppearance="?android:attr/textAppearanceMedium"
                android:text="@string/infosSurMedecin"
                android:id="@+id/textView4"
                android:background="#0061C2"
                android:textColor="#ffffffff"
                android:visibility="gone" />

            <EditText
                android:layout_width="match_parent"
                android:layout_height="wrap_content"
                android:inputType="date"
                android:ems="10"
                android:id="@+id/editNum"
                android:layout_gravity="center_horizontal"
                android:hint="@string/numero"
                android:visibility="gone"
                android:gravity="center"
                android:background="@drawable/rounded_corner_2"
                android:layout_marginTop="10dp"
                android:layout_marginBottom="5dp"
                android:selectAllOnFocus="false"
                android:paddingTop="5dp"
                android:paddingBottom="5dp" />

            <Spinner
                android:layout_width="match_parent"
                android:layout_height="wrap_content"
                android:id="@+id/spinner5"
                android:visibility="gone" />

            <TextView
                android:layout_width="match_parent"
                android:layout_height="wrap_content"
                android:textAppearance="?android:attr/textAppearanceMedium"
                android:text="@string/lieuxTravail"
                android:id="@+id/textView3"
                android:background="#0061C2"
                android:textColor="#ffffffff"
                android:visibility="gone" />


            <EditText
                android:layout_width="match_parent"
                android:layout_height="wrap_content"
                android:ems="10"
                android:id="@+id/editAdresse"
                android:hint="@string/adresse"
                android:visibility="gone"
                android:gravity="center"
                android:background="@drawable/rounded_corner_2"
                android:layout_marginTop="10dp"
                android:layout_marginBottom="5dp"
                android:selectAllOnFocus="false"
                android:paddingTop="5dp"
                android:paddingBottom="5dp" />

            <TextView
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:textAppearance="?android:attr/textAppearanceMedium"
                android:text="@string/position"
                android:id="@+id/tvPosition"
                android:layout_gravity="center_horizontal"
                android:visibility="gone" />

            <Button
                android:layout_width="match_parent"
                android:layout_height="wrap_content"
                android:text="@string/choisirPosition"
                android:id="@+id/btnChoisirPos"
                android:onClick="btnChoisirPosClick"
                android:nestedScrollingEnabled="false"
                android:visibility="gone" />

            <Button
                android:layout_width="match_parent"
                android:layout_height="wrap_content"
                android:text="@string/inscription"
                android:id="@+id/btnInscri"
                android:layout_alignRight="@+id/editNom"
                android:layout_alignEnd="@+id/editNom"
                android:onClick="btnInscriClick"
                android:nestedScrollingEnabled="false"
                android:layout_alignParentBottom="true"
                android:textColor="#ffffffff"
                android:background="@drawable/btn_back" />

        </LinearLayout>
    </ScrollView>

    <TextView
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:textAppearance="?android:attr/textAppearanceMedium"
        android:text="@string/avezVousUnCompte"
        android:id="@+id/textView2"
        android:onClick="textViewConnexClick"
        android:clickable="true"
        android:textColor="#ff0061c2"
        android:layout_weight="0.15"
        android:layout_alignParentRight="true"
        android:layout_alignParentEnd="true"
        android:layout_alignParentBottom="true"
        android:layout_alignParentLeft="true"
        android:layout_alignParentStart="true"
        android:gravity="center_horizontal" />



</RelativeLayout>