2017-11-24 1 views
0

이 레이아웃이 있습니다. 이 레이아웃은 중첩 된 조각BottomNavigationView 위의 컨테이너 레이아웃 설정

내가 BottomNavigationView 상단 위에 app_bar_main을 설정하는 방법
<?xml version="1.0" encoding="utf-8"?> 
<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/container" 
    android:layout_width="match_parent" 
    android:layout_height="match_parent" 
    tools:context="client.MainActivity"> 

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

    <android.support.design.widget.BottomNavigationView 
     android:id="@+id/navigation" 
     android:layout_width="0dp" 
     android:layout_height="wrap_content" 
     android:layout_marginEnd="0dp" 
     android:layout_marginStart="0dp" 
     android:background="?android:attr/windowBackground" 
     app:layout_constraintBottom_toBottomOf="parent" 
     app:layout_constraintLeft_toLeftOf="parent" 
     app:layout_constraintRight_toRightOf="parent" 
     app:menu="@menu/navigation" /> 

</android.support.constraint.ConstraintLayout> 

에 대한 BottomNavigationView 및 컨테이너를 포함?

때문에 지금 :

enter image description here BottomNavigationView이

+0

무엇을 의미합니까? – Mercato

+0

app_bar_main이 화면 하단에 그려집니다. 하지만 당신이 제공 한 사진의 상단 BottomNavigationView – ip696

+0

에 필요합니다, app_bar_main은 BottomNavigationView의 맨 위에 있습니다; 그렇지 않은가? – Mercato

답변

-1

BottomNavigationDrawer은보기입니다 크로스, 그래서 당신이로 레이아웃 할 수 있습니다 : 나는있는 LinearLayout과 채워진로 대체

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

<include 
    android:layout_weight="1"" 
    layout="@layout/app_bar_main" 
    android:layout_width="match_parent" 
    android:layout_height="0dp" /> 

<android.support.design.widget.BottomNavigationView 
    android:id="@+id/navigation" 
    android:layout_width="match_parent" 
    android:layout_height="wrap_content" 
    android:background="?android:attr/windowBackground" 
    app:menu="@menu/navigation" /> 

</LinearLayout> 

주 화면의 나머지 공간에 대한 content_view.

당신은 해결책이 될 내가 겹쳐에서 BottomNavigationView을 방지하기 위해 FrameLayout을 사용했다

1

content_view의 ID를 가지고 부모 탐색 위와 아래를 만들 것 ConstraintLayout을 (나던 레이아웃을 위해 필요) 사용하려는 경우 그 위에 레이아웃.

<?xml version="1.0" encoding="utf-8"?> 
<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/container" 
    android:layout_width="match_parent" 
    android:layout_height="match_parent" 
    tools:context="com.xxx.xxx.xxxx"> 
    <FrameLayout 
     android:id="@+id/fragment_container" 
     android:layout_width="0dp" 
     android:layout_height="0dp" 
     app:layout_constraintTop_toTopOf="parent" 
     app:layout_constraintBottom_toTopOf="@+id/navigation" 
     app:layout_constraintLeft_toLeftOf="parent" 
     app:layout_constraintRight_toRightOf="parent"> 
     <include 
      layout="@layout/app_bar_main" 
      android:layout_width="match_parent" 
      android:layout_height="match_parent" /> 
    </FrameLayout> 
    <android.support.design.widget.BottomNavigationView 
     android:id="@+id/navigation" 
     android:layout_width="0dp" 
     android:layout_height="wrap_content" 
     android:layout_marginEnd="0dp" 
     android:layout_marginStart="0dp" 
     android:background="?android:attr/windowBackground" 
     app:layout_constraintBottom_toBottomOf="parent" 
     app:layout_constraintLeft_toLeftOf="parent" 
     app:layout_constraintRight_toRightOf="parent" 
     app:menu="@menu/navigation" /> 
</android.support.constraint.ConstraintLayout> 
관련 문제