2016-08-24 3 views
0

탐색보기 조각을 만들려고합니다. 나는 이것을 창조한다. 그것은 작동합니다. 그러나 그것은 신중하게 보여주지 않습니다. 2 xml 코드가 있습니다.탐색보기 레이아웃 조각이 표시되지 않음

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

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

<FrameLayout 
    android:id="@+id/fragment_container" 
    android:layout_width="match_parent" 
    android:layout_height="match_parent"> 

</FrameLayout> 


<android.support.design.widget.FloatingActionButton 
    android:id="@+id/fab" 
    android:layout_width="wrap_content" 
    android:layout_height="wrap_content" 
    android:layout_gravity="bottom|end" 
    android:layout_margin="@dimen/fab_margin" 
    app:srcCompat="@android:drawable/ic_dialog_email" /> 

그리고 내 두 번째 XML 코드

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

<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" /> 
    <FrameLayout 
     android:id="@+id/fragment_container" 
     android:layout_width="match_parent" 
     android:layout_height="match_parent"> 

    </FrameLayout> 

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


<android.support.design.widget.FloatingActionButton 
    android:id="@+id/fab" 
    android:layout_width="wrap_content" 
    android:layout_height="wrap_content" 
    android:layout_gravity="bottom|end" 
    android:layout_margin="@dimen/fab_margin" 
    app:srcCompat="@android:drawable/ic_dialog_email" /> 

01 처음 코드를 사용하는 경우 23,

enter image description here

그것은 좌측 그림에 출력을 제공한다. 두 번째 코드를 사용하면 오른쪽 그림에서 출력됩니다. 이 문제를 어떻게 해결할 수 있습니까? 정말 고맙습니다.

enter image description here

fragment_main.xml

<FrameLayout 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="com.example.hp.myapplication.MainFragment"> 

<!-- TODO: Update blank fragment layout --> 

<Button 
    android:text="Burası Ana Sayfa Fragmenti" 
    android:layout_width="match_parent" 
    android:layout_height="61dp" 
    android:id="@+id/button" /> 

<TextView 
    android:layout_width="match_parent" 
    android:layout_height="61dp" 
    android:text="@string/hello_blank_fragment" /> 

activity_main.xml

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

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

+0

당신이 무엇을 예상 된 결과이며, 또한 전체 XML 파일이 도움이 될 것이다 게시 할 수 사용할 수있는 단편 센터의 콘텐츠를하려면? –

+0

오른쪽을 만들고 싶습니다. 툴바 영역에 표시됩니까? 안 그래? –

+0

만약 내가 왼쪽면 오른쪽면처럼 보이지 않는다. –

답변

0

귀하의 framgent 컨테이너는 툴바 아래에 있으며 화면의 전체 높이와 전체 높이를 차지합니다.

수직 당신이

<FrameLayout 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" 
    android:gravity="center_vertical" 
    tools:context="com.example.hp.myapplication.MainFragment"> 

    <!-- TODO: Update blank fragment layout --> 

    <Button 
    android:text="Burası Ana Sayfa Fragmenti" 
    android:layout_width="match_parent" 
    android:layout_height="61dp" 
    android:id="@+id/button" /> 

    <TextView 
    android:layout_width="match_parent" 
    android:layout_height="61dp" 
    android:text="@string/hello_blank_fragment" /> 

</Framelayout> 
관련 문제