2016-03-27 58 views
0
<android.support.v4.widget.DrawerLayout 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:id="@+id/drawer_layout" 
     android:fitsSystemWindows="true" 
     tools:context="com.example.sujin.trinity.HomePageActivity"> 

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

      android:background="#ffffff"> 

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

     <include layout="@layout/content_home_page" /> 
     <fragment 
      android:id="@+id/fragment_navigation_drawer" 
      android:layout_width="350dp" 
      android:layout_height="match_parent" 
      android:layout_gravity="start" 
      app:layout="@layout/fragment_navigation_drawer" 
      tools:layout="@layout/fragment_navigation_drawer" 
      android:name="com.example.sujin.trinity.NavigationDrawerFragment" 
      /> 
      </android.support.v4.widget.DrawerLayout> 

content düzen dosyasıdır: android:background="#ffffff" kullanıldığı zamanDrawerLayout Hata ile AppBarLayout çözmek için nasıl İşte

 <?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:paddingTop="@dimen/activity_vertical_margin" 
     app:layout_behavior="@string/appbar_scrolling_view_behavior" 
     tools:context="com.example.sujin.trinity.HomePageActivity" 
     tools:showIn="@layout/activity_home_page"> 

     <CalendarView 
      android:layout_width="wrap_content" 
      android:layout_height="wrap_content" 
      android:id="@+id/calendarView" 
      android:layout_alignParentTop="true" 
      android:layout_centerHorizontal="true" 
      android:layout_marginTop="182dp" /> 

     <TextView 
      android:layout_width="wrap_content" 
      android:layout_height="wrap_content" 
      android:textAppearance="?android:attr/textAppearanceLarge" 
      android:text="Large Text" 
      android:id="@+id/textView" 
      android:layout_alignParentTop="true" 
      android:layout_centerHorizontal="true" 
      android:layout_marginTop="84dp" 
      android:textColor="#000000" /> 
    </RelativeLayout> 

When <code>android:background="#ffffff"</code> is used, following output is observed but the other elements like TextView are not visible.

[When <code>android:background</code> is not used, following output is observed but the other elements like TextView are not visible.

, ilk çıkış görülmektedir ancak diğer TextView gibi öğeler görünmez.

android:background="#ffffff" kullanılmadığında, ikinci çıktı gözlenir, ancak TextView gibi diğer öğeler görünmez. Bu hatayı nasıl çözebilirim?

+0

Ne TextView göstermeye çalışıyorsunuz? Lütfen içerik düzeninizi ekleyin. –

+1

"AppBarLayout", "ViewGroup" ana içeriğinin içinde olmalıdır. Şu anda ana içeriğin kendisi gibi davranıyor. 'AppBarLayout' ve' 'd düzenini başka bir' ViewGroup' içine yerleştirin; ör. bir "LinearLayout" veya bir "RelativeLayout". –

+0

@ cricket_007 İçerik düzenini ekledim –

cevap

0

fragment_navigation_drawer için neden fragmanı kullanıyorum ???? Aşağıdaki gibi android stüdyo standart kod adlı kullanım: Araç çubuğunuza ve içerik için başka xml aşağıda gibi

<android.support.v4.widget.DrawerLayout 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/drawer_layout" 
    android:layout_width="match_parent" 
    android:layout_height="match_parent" 
    android:fitsSystemWindows="true" 
    tools:openDrawer="start"> 

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

    <android.support.design.widget.NavigationView 
     android:id="@+id/nav_view" 
     android:layout_width="wrap_content" 
     android:layout_height="match_parent" 
     android:layout_gravity="start" 
     android:fitsSystemWindows="true" 
     app:headerLayout="@layout/nav_header_main" 
     app:menu="@menu/activity_main_drawer" /> 
</android.support.v4.widget.DrawerLayout> 

ve yapmak:

<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=".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> 

    <include layout="@layout/content_home_page" /> 

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

Ben size yardımcı olabilir umuyoruz.