2016-12-22 3 views
0

Ich versuche, eine Login-Aktivität für Android-Anwendung zu machen. App funktioniert gut im Potrait-Modus, aber im Landscape-Modus, kann die Benutzeroberfläche nicht vollständig unterbringen und so ein Teil der Benutzeroberfläche ist nicht sichtbar. Ich habe auf alle damit verbundenen SO Frage, aber keine geholfen.
Device- Motorola X-Art-Eibisch
Kann die Benutzeroberfläche nicht scrollbar machen

-Code für activity_login.xml

<?xml version="1.0" encoding="utf-8"?> 
<android.support.design.widget.CoordinatorLayout xmlns:android="http://schemas.android.com/apk/res/android" 
    xmlns:tools="http://schemas.android.com/tools" 
    android:layout_width="match_parent" 
    android:layout_height="match_parent" 
    tools:context=".SignupActivity" 
    android:scrollbars="vertical"> 

    <android.support.design.widget.AppBarLayout 
     android:layout_width="match_parent" 
     android:layout_height="wrap_content" 
     android:theme="@style/MyMaterialTheme.AppBarOverlay"> 

     <include android:layout_height="wrap_content" 
      android:layout_width="match_parent" 
      layout="@layout/toolbar" /> 

    </android.support.design.widget.AppBarLayout> 

    <include layout="@layout/content_login" /> 
</android.support.design.widget.CoordinatorLayout> 

-Code für content_login.xml

<?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" 
    xmlns:tools="http://schemas.android.com/tools" 
    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:background="#1E1E24" 
    android:paddingTop="@dimen/activity_vertical_margin" 
    app:layout_behavior="@string/appbar_scrolling_view_behavior" 
    tools:context=".SignupActivity" 
    tools:showIn="@layout/activity_login"> 

    <TextView 
     android:layout_width="fill_parent" 
     android:layout_height="wrap_content" 
     android:gravity="center" 
     android:id="@+id/first" 
     android:textColor="@color/primary_text_default_material_dark" 
     android:textSize="@dimen/title_font" 
     android:textStyle="bold" 
     android:layout_marginBottom="@dimen/padding_10" 
     android:text="Login Activity" 
     /> 

    <View 
     android:id="@+id/second" 
     android:layout_width="match_parent" 
     android:layout_below="@id/first" 
     android:layout_height="@dimen/contacting_post_staff_view_width" 
     android:background="@color/photo_border"/> 

    <TextView 
     android:layout_width="fill_parent" 
     android:layout_height="wrap_content" 
     android:gravity="center" 
     android:id="@+id/third" 
     android:layout_below="@id/second" 
     android:textColor="@color/primary_text_default_material_dark" 
     android:textSize="@dimen/sub_title_font" 
     android:textStyle="bold" 
     android:layout_marginTop="@dimen/padding_10" 
     android:text="Hey ! This is a sample App for Login Activity" 
     /> 


    <LinearLayout 
     android:layout_marginTop="@dimen/fragment_main_marginTop_35" 
     android:layout_width="match_parent" 
     android:orientation="vertical" 
     android:gravity="center" 
     android:layout_below="@id/third" 
     android:layout_height="wrap_content"> 
     <EditText 
      android:background="@drawable/edit_text_bg" 
      android:layout_width="match_parent" 
      android:layout_marginTop="@dimen/contacting_post_staff_marginTop_15" 
      android:layout_height="wrap_content" 
      android:id="@+id/edit_name" 
      android:hint="@string/enter_name" 
      android:inputType="textPersonName|textCapWords" /> 

     <Spinner 
      android:id="@+id/spinner_country" 
      android:layout_width="fill_parent" 
      android:layout_height="wrap_content" 
      android:dropDownWidth="@dimen/contacting_post_staff_spinner_width" 
      android:layout_marginTop="@dimen/contacting_post_staff_marginTop_15" /> 
     <Button 
      android:id="@+id/loginButton" 
      style="@style/NavigateButton" 
      android:text="@string/login" 
      android:layout_marginTop="@dimen/fragment_main_marginTop_35"/> 

    </LinearLayout> 



</RelativeLayout> 

-Code für toolbar.xml

<?xml version="1.0" encoding="utf-8"?> 
<android.support.v7.widget.Toolbar 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="wrap_content" 
    android:id="@+id/toolbar" 
    android:background="@color/background_textview" 
    android:minHeight="?attr/actionBarSize" 
    android:fitsSystemWindows="true" 
    app:theme="@style/ThemeOverlay.AppCompat.Dark.ActionBar" 
    > 
</android.support.v7.widget.Toolbar> 

Um dies zu lösen, versuche ich, die Benutzeroberfläche scrollbar zu machen, so dass der Benutzer zu einem Teil scrollen kann, der im Querformat nicht sichtbar ist.

Was ich versucht habe-

1. Ich habe versucht, unten im Inneren Scroll setzen

umfassen layout = "@ Layout/content_login" />

2 Ich habe versucht Putting oben in Lineares Layout und dann Lineares Layout in Scrollview.

Und es gibt viele andere Dinge, mit denen ich spielte, aber keiner half. Bitte helfen Sie mir dabei. Vielen Dank.

Antwort

0

versuchen Sie, das Stammelement von content_login.xml als scrollview zu erstellen. Sie können verschachtelte Layouts mit dem aktuellen relativen Layout in einer neuen Bildlaufansicht haben.

Alternativ können Sie die Ausrichtung der Aktivität im Hochformat mit Android: screenOrientation = "Hochformat" unter dem Aktivitäts-Tag in AndroidManifest.xml korrigieren, wenn dies kein Problem ist.

Verwenden Sie ConstraintLayout auch, um den Umgang mit verschachtelten Layouts zu vermeiden.

+0

Vielen Dank !! Ihre erste Methode hat mit einigen kleinen Änderungen funktioniert. –

+0

froh, dass wir helfen können! – sats

0
<android.support.constraint.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android" 
xmlns:app="http://schemas.android.com/apk/res-auto" 
xmlns:tools="http://schemas.android.com/tools" 
android:id="@+id/activity_main" 
android:layout_width="match_parent" 
android:layout_height="match_parent" 
tools:context=".SignupActivity"> 

<ScrollView 
    android:layout_width="0dp" 
    android:layout_height="0dp" 
    app:layout_constraintBottom_toBottomOf="parent" 
    app:layout_constraintRight_toRightOf="parent" 
    app:layout_constraintLeft_toLeftOf="parent"> 

    <LinearLayout 
     android:layout_width="match_parent" 
     android:layout_height="match_parent" 
     app:layout_behavior="@string/appbar_scrolling_view_behavior" 
     tools:context=".SignupActivity" 
     android:orientation="vertical" 
     tools:showIn="@layout/activity_login"> 

     <TextView 
      android:layout_width="fill_parent" 
      android:layout_height="wrap_content" 
      android:gravity="center" 
      android:id="@+id/first" 
      android:textColor="@color/primary_text_default_material_dark" 
      android:textSize="@dimen/title_font" 
      android:textStyle="bold" 
      android:layout_marginBottom="@dimen/padding_10" 
      android:text="Login Activity" 
      /> 

     <View 
      android:id="@+id/second" 
      android:layout_width="match_parent" 
      android:layout_below="@id/first" 
      android:layout_height="@dimen/contacting_post_staff_view_width" 
      android:background="@color/photo_border"/> 

     <TextView 
      android:layout_width="fill_parent" 
      android:layout_height="wrap_content" 
      android:gravity="center" 
      android:id="@+id/third" 
      android:layout_below="@id/second" 
      android:textColor="@color/primary_text_default_material_dark" 
      android:textSize="@dimen/sub_title_font" 
      android:textStyle="bold" 
      android:layout_marginTop="@dimen/padding_10" 
      android:text="Hey ! This is a sample App for Login Activity" 
      /> 


     <LinearLayout 
      android:layout_marginTop="@dimen/fragment_main_marginTop_35" 
      android:layout_width="match_parent" 
      android:orientation="vertical" 
      android:gravity="center" 
      android:layout_below="@id/third" 
      android:layout_height="wrap_content"> 
      <EditText 
       android:background="@drawable/edit_text_bg" 
       android:layout_width="match_parent" 
       android:layout_marginTop="@dimen/contacting_post_staff_marginTop_15" 
       android:layout_height="wrap_content" 
       android:id="@+id/edit_name" 
       android:hint="@string/enter_name" 
       android:inputType="textPersonName|textCapWords" /> 

      <Spinner 
       android:id="@+id/spinner_country" 
       android:layout_width="fill_parent" 
       android:layout_height="wrap_content" 
       android:dropDownWidth="@dimen/contacting_post_staff_spinner_width" 
       android:layout_marginTop="@dimen/contacting_post_staff_marginTop_15" /> 
      <Button 
       android:id="@+id/loginButton" 
       style="@style/NavigateButton" 
       android:text="@string/login" 
       android:layout_marginTop="@dimen/fragment_main_marginTop_35"/> 
     </LinearLayout> 
    </LinearLayout> 
</ScrollView> 

Versuchen Sie dieses, fügen Sie alle die Polsterung, Ränder, Höhe, Breite usw., wie Sie wollen und alle Layoutbeschränkungen

Verwandte Themen