2016-12-22 9 views
0

Androidアプリケーションのログインアクティビティを作成しようとしています。アプリはPotraitモードでは正常に動作していますが、ランドスケープモードではUIが完全に対応できないため、UIの一部が表示されません。関連するすべての質問を参照しましたが、役に立たなかった。
、デバイスにモトローラXスタイルマシュマロ
UIをスクロールできない

コード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> 

のコードtoolbar.xml

ため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> 

コードについて

これを解決するために、ユーザーが横向きモードで表示されない部分にスクロールできるようにUIをスクロール可能にしようとしています。私が試してみました

- 私はScrollview

内で以下

を入れて試してみました

1.は、私が入れて試してみましたレイアウト= "@レイアウト/ content_login" />

2、線形レイアウトの中で上に移動し、次にScrollview内で線形レイアウトに移動します。

他にも多くのものがありますが、何も助けてくれませんでした。 これで私を助けてください。本当にありがとうございます。

答えて

0

content_login.xmlのルート要素をscrollviewにしてみてください。 新しいスクロールビュー内で、現在の相対レイアウトでレイアウトをネストすることができます。

また、AndroidManifest.xmlのactivityタグの下で、android:screenOrientation = "portrait"を使用して、アクティビティの向きをポートレートに修正することもできます。

また、ConstraintLayoutを使用すると、ネストされたレイアウトを扱う手間がなくなります。

+0

おかげで多くのことをあなたが望むように、すべてのパディング、マージン、高さ、幅などを追加し、すべてのレイアウト制約、これを試してみてください!!あなたの最初の方法は若干の変更を加えて機能しました。 –

+0

何か助けになってうれしい! – 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> 

関連する問題