2017-02-15 6 views
0

私のAppBarは奇妙なことをしています。 これは720x1280の画面上に表示されます: enter image description hereAppBarの間違った高さ

どのように見えるのですか?これは1080x1920の画面のようです: enter image description here 私はapp_bar_main.xmlのツールバーの高さで遊んでいましたが、気に入らなかったので、デフォルトのattr/actionBarSize値に戻しました。何が問題なの?ここに私のapp_bar_main.xmlは次のとおりです。

<?xml version="1.0" encoding="utf-8"?> 
<android.support.design.widget.CoordinatorLayout 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:fitsSystemWindows="true" 
tools:context="com.koostamas.justtry.MainActivity"> 

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

    <android.support.v7.widget.Toolbar 
     android:id="@+id/toolbar" 
     android:layout_width="match_parent" 
     android:layout_height="?attr/actionBarSize" 
     android:background="?attr/colorPrimary" 
     app:popupTheme="@style/AppTheme.PopupOverlay" /> 

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

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

そして、ここでは私のactivity_main.xmlです:

<?xml version="1.0" encoding="utf-8"?> 
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" 
android:layout_width="match_parent" 
android:layout_height="match_parent" 
android:orientation="vertical" > 

<include 
    android:id="@+id/app_bar" 
    layout="@layout/app_bar_main" 
    android:layout_width="match_parent" 
    android:layout_height="wrap_content" /> 
<android.support.v4.widget.DrawerLayout 
    xmlns:android="http://schemas.android.com/apk/res/android" 
    android:id="@+id/drawerLayout" 
    android:layout_width="match_parent" 
    android:layout_height="match_parent"> 

    <FrameLayout 
     android:orientation="vertical" 
     android:layout_width="match_parent" 
     android:layout_height="match_parent" 
     android:id="@+id/containerView"> 
    </FrameLayout> 


    <RelativeLayout 
     android:layout_width="wrap_content" 
     android:layout_height="match_parent" 
     android:id="@+id/drawerPane" 
     android:layout_gravity="start"> 

     <!-- List of Actions (pages) --> 
     <ListView 
      android:id="@+id/navList" 
      android:layout_width="wrap_content" 
      android:layout_height="match_parent" 
      android:choiceMode="singleChoice" 
      android:background="@color/busblue"/> 

    </RelativeLayout> 

</android.support.v4.widget.DrawerLayout> 

</LinearLayout> 
+0

であなたのactivity_main.xmlコードは、あなたの高さを解決し、レイアウトコード –

+0

を含んからの高さと幅の属性を削除更新しますが、ナビゲーションバーとアプレットの下のフラグメントが消え、白い背景だけが表示されます。 –

答えて

1

コードを更新してみてください。私の現在では、この問題はあなたの意見です。あなたのアプローチはこれを加えるのは間違いです。ツールバーのみを含める場合、coordinateLayoutAppBarLayoutの必要性は何ですか?この

<?xml version="1.0" encoding="utf-8"?> 
<android.support.v7.widget.Toolbar 
    android:id="@+id/toolbar" 
    android:layout_width="match_parent" 
    android:layout_height="?attr/actionBarSize" 
    android:background="?attr/colorPrimary" 
    app:popupTheme="@style/AppTheme.PopupOverlay" /> 

更新app_bar_main.xml OCDEこの

<?xml version="1.0" encoding="utf-8"?> 
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" 
    android:layout_width="match_parent" 
    android:layout_height="match_parent" 
    android:orientation="vertical"> 
<android.support.v4.widget.DrawerLayout xmlns:android="http://schemas.android.com/apk/res/android" 
    android:id="@+id/drawerLayout" 
    android:layout_width="match_parent" 
    android:layout_height="match_parent"> 

    <include 
     android:id="@+id/app_bar" 
     layout="@layout/app_bar_main" /> 

    <FrameLayout 
     android:id="@+id/containerView" 
     android:layout_width="match_parent" 
     android:layout_height="match_parent" 
     android:orientation="vertical"></FrameLayout> 

    <RelativeLayout 
     android:id="@+id/drawerPane" 
     android:layout_width="wrap_content" 
     android:layout_height="match_parent" 
     android:layout_gravity="start"> 

     <!-- List of Actions (pages) --> 
     <ListView 
      android:id="@+id/navList" 
      android:layout_width="wrap_content" 
      android:layout_height="match_parent" 
      android:background="@color/busblue" 
      android:choiceMode="singleChoice" /> 

    </RelativeLayout> 

</android.support.v4.widget.DrawerLayout> 

+0

あなたがappbarがその下の断片の後ろにあると言ったように私がそれをインクルードすると、drawerlayoutの外にインクルードを移動すると(私はappbarの下でナビゲーションドロワを開始したい)、それは前と同じように見えます。 –

+0

okもう1つのxmlを更新します.1つはxmlの上にあるこれらのものを除外し、1つだけが –

+0

になったと結論づけます。あなたが投稿したxmlは正しくありませんでしたが、私はCoordinatorLayoutが必要ではなく、あなたが正しいと書いています。それがそれを解決しました。ありがとう。投稿を更新してください。他の人が回答を必要とする場合は、明らかになります。 –

関連する問題