1
私の機能として、ドロワーメニューとボトムナビゲーションを使用する必要があります。下のナビゲーションにhttps://github.com/roughike/BottomBarを使用しています。ボトムナビゲーションを追加するときにツールバー上部の不要なスペースを取得する
私は3つのタブだけを使ってボトムナビゲーションを使っても問題ありませんが、4,5つのタブでそれを伸ばすと、ツールバーの上部に空白が表示されます。
ここでは、ナビゲーションの追加に使用したコードスニペットを示します。
activity_main.xml
<?xml version="1.0" encoding="utf-8"?>
<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" android:background="@android:color/white" android:elevation="7dp" android:fitsSystemWindows="false" android:scrollbars="none">
<LinearLayout android:layout_width="match_parent" android:layout_height="match_parent" android:orientation="vertical">
<include android:id="@+id/tool_bar" layout="@layout/row_main_toolbar_header"></include>
<!-- The main content view -->
<FrameLayout android:id="@+id/contentFrame" android:layout_width="match_parent" android:layout_height="match_parent" android:layout_marginBottom="@dimen/dp_1" android:layout_marginTop="@dimen/dp_10" android:background="@android:color/white" android:orientation="vertical"></FrameLayout>
</LinearLayout>
<ListView android:id="@+id/lvDrawerMenu" android:layout_width="match_parent" android:layout_height="match_parent" android:layout_gravity="start" android:background="@android:color/white" android:scrollbars="none"></ListView>
</android.support.v4.widget.DrawerLayout>
与えられたライブラリを使用して下部のナビゲーションのために必要なすべてのコンポーネントが何もありません。
下部ナビゲーションを追加するMainActivity.javaにあります。
BottomBar bottomBar = BottomBar.attach(this, savedInstanceState);
bottomBar.setItemsFromMenu(R.menu.home_tab_menu, new OnMenuTabSelectedListener() {
@Override
public void onMenuItemSelected(int itemId) {
switch (itemId) {
case R.id.recent_item:
break;
case R.id.favorite_item:
break;
case R.id.location_item:
break;
case R.id.planning_item:
break;
case R.id.saver_item:
break;
}
}
});
row_main_toolbar_main.xml
<?xml version="1.0" encoding="utf-8"?>
<android.support.v7.widget.Toolbar xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="@android:color/white"
android:elevation="@dimen/dp_4"
android:gravity="center"
android:theme="@style/ThemeOverlay.AppCompat.Dark">
<RelativeLayout
android:id="@+id/RelativeLayout01"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:padding="10dp">
<TextView
android:id="@+id/txtTBTitle"
style="@style/CustomBlackHeaderText"
android:layout_alignParentLeft="true"
android:layout_alignParentStart="true"
android:layout_alignParentTop="true"
android:layout_centerVertical="true"
android:layout_toLeftOf="@+id/imgTB4" />
<ImageView
android:id="@+id/imgTB4"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerVertical="true"
android:layout_toLeftOf="@+id/imgTB3"
android:layout_toStartOf="@+id/imgTB3"
android:padding="@dimen/dp_5" />
<ImageView
android:id="@+id/imgTB3"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentTop="true"
android:layout_centerVertical="true"
android:layout_marginLeft="@dimen/dp_5"
android:layout_toLeftOf="@+id/imgTB2"
android:layout_toStartOf="@+id/imgTB2"
android:padding="@dimen/dp_5" />
<ImageView
android:id="@+id/imgTB2"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentTop="true"
android:layout_centerVertical="true"
android:layout_marginLeft="@dimen/dp_5"
android:layout_toLeftOf="@+id/imgTB1"
android:layout_toStartOf="@+id/imgTB1"
android:padding="@dimen/dp_5" />
<ImageView
android:id="@+id/imgTB1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentEnd="true"
android:layout_alignParentRight="true"
android:layout_alignTop="@+id/txtTBTitle"
android:layout_centerVertical="true"
android:layout_marginLeft="@dimen/dp_5"
android:padding="@dimen/dp_5" />
</RelativeLayout>
</android.support.v7.widget.Toolbar>
'row_main_toolbar_header'のコードを追加 –
@AnshulTyagi row_main_toolbar_header.xmlを追加して投稿を編集しました。確認してください。 –
'android:padding =" 10dp "'を削除して教えてください –