2017-10-10 5 views
0

チャットしようとしています。 は、ToolBarおよびBottomNavigationVIewを有する。Android BottomNavigationVIewオーバーラップフラグメントのコンテンツ

チャットfragmentrecyclerVieweditTextImageButtonを持っていますが、私はフラグメントをロードするときBottomNavigationVIewEditTextと私はこれがBottomNavigationVIewルックスの項目が重要であるが、Androidのメーカーであれば知らないImageButton

と重なりますそれはより小さく、ではない。また、私がandroid:layout_above="@+id/navigation"使用して、ツールバー のような例えばそれは動作しません enter image description here

enter image description here

私は多くの方法を試してみましたが、私はあなたがそれを

activity_main.xml

<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:id="@+id/activity_home" 
android:layout_width="match_parent" 
android:layout_height="match_parent" 
tools:context=".MainActivity"> 

<LinearLayout 
    android:layout_width="match_parent" 
    android:layout_height="match_parent" 
    android:orientation="vertical"> 

    <android.support.v7.widget.Toolbar xmlns:app="http://schemas.android.com/apk/res-auto" 
     android:id="@+id/toolbar" 
     android:layout_width="match_parent" 
     android:layout_height="?attr/actionBarSize" 
     android:background="?attr/colorPrimary" 
     app:popupTheme="@style/ThemeOverlay.AppCompat.Light" 
     app:theme="@style/ThemeOverlay.AppCompat.Dark.ActionBar"> 

     <LinearLayout 
      android:layout_width="match_parent" 
      android:layout_height="match_parent" 
      android:orientation="horizontal"> 

      <TextView 
       android:id="@+id/tv_parent_name" 
       android:layout_width="wrap_content" 
       android:layout_height="wrap_content" 
       android:layout_gravity="center" 
       android:layout_weight="1" 
       android:text="@string/parent_name" 
       android:textSize="20sp" /> 


      <de.hdodenhof.circleimageview.CircleImageView xmlns:app="http://schemas.android.com/apk/res-auto" 
       android:id="@+id/student_photo" 
       android:layout_width="55dp" 
       android:layout_height="55dp" 
       android:layout_alignParentEnd="true" 

       android:layout_alignParentRight="true" 
       android:layout_gravity="right|center" 
       android:onClick="onClick" 
       android:padding="4dp" 
       android:src="@drawable/foto" 
       app:civ_border_color="@color/iron" 
       app:civ_border_width="1dp" /> 

     </LinearLayout> 

    </android.support.v7.widget.Toolbar> 


    <FrameLayout 
     android:id="@+id/frame_layout" 
     android:layout_width="match_parent" 
     android:layout_height="match_parent" 
     android:layout_alignParentTop="true" 
     android:layout_above="@+id/navigation"> 

     <ProgressBar 
      android:id="@+id/pb_loading" 
      android:layout_width="wrap_content" 
      android:layout_height="wrap_content" 
      android:layout_gravity="center" 
      android:visibility="invisible" /> 
    </FrameLayout> 

</LinearLayout> 

<android.support.design.widget.BottomNavigationView 
    android:id="@+id/navigation" 
    android:layout_width="match_parent" 
    android:layout_height="wrap_content" 
    android:layout_alignParentBottom="true" 
    android:background="@color/primary_dark" 
    app:itemIconTint="@color/nav_item_state_list" 
    app:itemTextColor="@color/nav_item_state_list" 
    app:menu="@menu/menu_navigation" /> 
</RelativeLayout> 

chat_fragment.xml

<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" 
android:orientation="vertical" android:layout_width="match_parent" 
android:layout_height="match_parent"> 

<android.support.v7.widget.RecyclerView 
    android:id="@+id/messages" 
    android:layout_width="match_parent" 
    android:layout_height="0dp" 
    android:layout_weight="1" 
    android:paddingLeft="@dimen/activity_horizontal_margin" 
    android:paddingRight="@dimen/activity_horizontal_margin" 
    android:scrollbars="vertical" 
    android:scrollbarStyle="outsideOverlay"/> 

<LinearLayout 
    android:layout_width="match_parent" 
    android:layout_height="wrap_content" 
    android:paddingLeft="@dimen/activity_horizontal_margin" 
    android:paddingRight="@dimen/activity_horizontal_margin" 
    android:orientation="horizontal" 
    android:gravity="center_vertical"> 

    <EditText 
     android:id="@+id/message_input" 
     android:layout_width="0dp" 
     android:layout_height="wrap_content" 
     android:layout_weight="1" 
     android:hint="@string/prompt_message" 
     android:imeActionId="@+id/send" 
     android:imeActionLabel="@string/action_send" 
     android:imeOptions="actionSend" 
     android:inputType="text" 
     android:maxLines="1"/> 
    <ImageButton 
     android:id="@+id/send_button" 
     android:layout_width="wrap_content" 
     android:layout_height="wrap_content" 
     android:src="@android:drawable/ic_menu_send" 
     android:contentDescription="@string/action_send"/> 

</LinearLayout> 

</LinearLayout> 

fragment.java

   FragmentManager fragmentManager = getFragmentManager(); 
      FragmentTransaction fragmentTransaction = fragmentManager.beginTransaction(); 
      fragmentManager.popBackStackImmediate(); 
      fragmentTransaction.replace(R.id.frame_layout, chat); 
      fragmentTransaction.addToBackStack(null); 
      fragmentTransaction.commit(); 

答えて

1

を、垂直に設定向きでルートレイアウトLinearLayoutを作ります。ルートレイアウト内のLinearLayoutを削除します。彼らはLinearLayout内部で動作しないので、

android:layout_width="match_parent" 
android:layout_height="0dp" 
android:layout_weight="1" 

最後に、すべてのalign...ものを削除します。そして、あなたのFrameLayoutため、以下の高さ、幅の設定を設定します。

0

をしなければならないんカントあなたのFrameLaを動かすYOUTのLinearLayoutのうちコード(私はのLinearLayout後の平均)、そしてまた、あなたのフレームにこのコードを追加する必要があります。あなたのactivity_main.xml

android:layout_above="@+id/navigation" 
関連する問題