2017-01-21 5 views
1

レイアウトに問題があります。私は風景と肖像画の両方で動作する1つのXMLファイルを構築しようとしています。 1つの特定のレイアウトでは、回転(ポートレートからランドスケープまで)で、レイアウトは拡大するようです。すべてのオブジェクトがそこにあるにもかかわらず、大きなギャップができます。アンドロイド:オリエンテーションでレイアウトサイズが変更されます

これは、ポートレートでの表示方法です。

enter image description here

これらそれが回転(ランドスケープ)の後でどのように描いています。

enter image description here

私のxmlファイルは次のとおりです。

<?xml version="1.0" encoding="utf-8"?> 



<LinearLayout 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="match_parent" 
    android:background="@color/colorPrimaryDark" 
    android:orientation="vertical"> 


    <android.support.design.widget.CoordinatorLayout 
     android:layout_width="match_parent" 
     android:layout_height="fill_parent" 
     android:fitsSystemWindows="false" 
     android:id="@+id/coordintorLayout"> 



     <com.andremion.floatingnavigationview.FloatingNavigationView 
      android:id="@+id/floating_navigation_view" 
      android:layout_width="match_parent" 
      android:layout_height="wrap_content" 
      android:layout_margin="@dimen/fab_margin" 
      app:layout_anchor="@+id/toolbar" 
      app:layout_anchorGravity="bottom|end" 
      app:drawMenuBelowFab="true" 
      app:headerLayout="@layout/navigation_view_header" 
      app:menu="@menu/menu" /> 

     <LinearLayout 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:background="@color/colorPrimaryDark" 
      android:orientation="vertical"> 

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

      <ScrollView xmlns:android="http://schemas.android.com/apk/res/android" 
       android:layout_width="match_parent" 
       android:layout_height="wrap_content" > 

       <LinearLayout 
        android:id="@+id/footer" 
        android:layout_width="match_parent" 
        android:layout_height="wrap_content" 
        android:orientation="vertical" 
        android:layout_gravity="center" 
        android:gravity="bottom|center"> 

        <!-- 
        <include 
         layout="@layout/single_item_customize" 
         android:layout_width="match_parent" 
         android:layout_height="wrap_content"/> 
        --> 
        <ViewStub 
         android:id="@+id/layout_stub1" 
         android:inflatedId="@+id/inflated_layout_stub1" 
         android:layout_width="match_parent" 
         android:layout_height="0dp" 
         android:layout_weight="0.75" /> 

        <ViewStub 
         android:id="@+id/layout_stub2" 
         android:inflatedId="@+id/inflated_layout_stub2" 
         android:layout_width="match_parent" 
         android:layout_height="0dp" 
         android:layout_weight="0.75" /> 
        <ViewStub 
         android:id="@+id/layout_stub3" 
         android:inflatedId="@+id/inflated_layout_stub3" 
         android:layout_width="match_parent" 
         android:layout_height="0dp" 
         android:layout_weight="0.25" /> 

        <TextView 
         android:layout_width="match_parent" 
         android:layout_height="0px" 
         android:layout_weight="0.25" 
         android:inputType="textMultiLine" 
         android:ems="10" 
         android:id="@+id/editText" 
         android:background="@color/colorPrimaryDark" 
         android:clickable="false" 
         android:editable="false" 
         android:enabled="false" 
         android:focusable="false" 
         android:focusableInTouchMode="false" 
         android:freezesText="false" 
         android:linksClickable="false" 
         android:longClickable="false" 
         android:text="@string/default_message" /> 
       </LinearLayout > 
      </ScrollView> 
     </LinearLayout> 

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

</LinearLayout> 

私は何かが私のxmlと間違っていることをかなり確信しているが、私はそれを把握することはできません。

ありがとうございました。

PS:私はすでに私のマニフェスト内の

android:configChanges="orientation|screenSize|keyboardHidden" 

を持っています。

+0

こんにちは。解決策を質問のテキストに編集しないでください。スタックオーバーフローでは、答えが受け入れられたときに問題が解決されたとみなされます。編集した解決策を回答として投稿し、それを受け入れたものとしてマークしてください(あなた自身の回答を受け入れることを妨げる24時間の制限があるかもしれないので、約10時間以上待たなければなりません)。 – Dragomok

+0

申し訳ありません。私の間違い。それを変更しました。 –

答えて

0

あなたは再びので、あなたのファイル構造は以下の通りである必要があり、レイアウト、土地 の下で同じ名前のレイアウトを実装する必要があります。

MyProject/ 
    res/ 
     layout/    # default (portrait) 
      main.xml 
     layout-land/   # landscape 
      main.xml 

私は、これはあなたを助けることを願っています:)

+0

ありがとうございます。私はこれが "良い習慣"の一つだと思う - (ここでは初心者)。私はインテントごとに1つのXMLを使用して、これを実装しようとしています(完了できる場合)。 –

0

android:fillViewport="true"を使用してみてくださいのlayout_height属性をmatch_parentに変更してください。

+0

ありがとうございます。それはうまくいかなかった。私は同じ出力を得続けます。 –

1

溶液を見出した。 android:layout_gravity="top|center"と、第二のLinearLayout内部

android:layout_gravity="center"

が変更されました。

関連する問題