[更新]プロジェクトでBottombarライブラリとデフォルトの AndroidNavigation Drawer
を使用しました。シンプルになりましたTextView
Fragment
top が重なってToolbar
います。これは私のアクティビティ レイアウト コードです。
レイアウトのスクリーンショットはこちらで確認できます。
activity_main.xml
<?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"
tools:context=".MainActivity">
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical" >
<include layout="@layout/toolbar" />
<android.support.v4.widget.DrawerLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/drawer_layout"
android:layout_width="match_parent"
android:layout_height="match_parent" >
<FrameLayout
android:id="@+id/content_frame"
android:layout_width="match_parent"
android:layout_height="match_parent" />
<include
android:layout_width="@dimen/drawer_width"
android:layout_height="match_parent"
android:layout_gravity="start"
layout="@layout/list_view" />
</android.support.v4.widget.DrawerLayout>
</LinearLayout>
<!-- Start - Container to show Fragments -->
<FrameLayout
android:id="@+id/container"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_above="@+id/bottomBar" />
<!-- End - Container to show Fragments -->
<com.roughike.bottombar.BottomBar
android:id="@+id/bottomBar"
android:layout_width="match_parent"
android:layout_height="55dp"
android:layout_alignParentBottom="true"
android:background="@color/main_color_500"
app:bb_activeTabAlpha="1"
app:bb_inActiveTabAlpha="0.3"
app:bb_activeTabColor="@android:color/white"
app:bb_inActiveTabColor="@android:color/white"
app:bb_titleTextAppearance="@style/TextAppearance.AppCompat.Caption"
app:bb_showShadow="true"
app:bb_tabXmlResource="@xml/menu_bottombar" />
</RelativeLayout>
toolbar.xml
<?xml version="1.0" encoding="utf-8"?>
<android.support.v7.widget.Toolbar xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:id="@+id/toolbar"
android:layout_width="match_parent"
android:layout_height="?android:attr/actionBarSize"
android:background="@color/main_color_500"
app:popupTheme="@style/Theme.AppCompat.Light.DarkActionBar"
app:theme="@style/AppTheme.Title" />
list_view.xml
<?xml version="1.0" encoding="utf-8"?>
<ListView xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/list_view"
style="@style/ListViewStyle" />
OnCreate
メソッド(Navigation Drawer Code)のMainActivity
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar);
setSupportActionBar(toolbar);
//getSupportActionBar().setTitle("Sample Title");
mDrawerLayout = (DrawerLayout) findViewById(R.id.drawer_layout);
mTitle = mDrawerTitle = getTitle();
mDrawerList = (ListView) findViewById(R.id.list_view);
mDrawerLayout.setDrawerShadow(R.drawable.drawer_shadow,
GravityCompat.START);
View headerView = getLayoutInflater().inflate(
R.layout.header_navigation_drawer_social, mDrawerList, false);
ImageView iv = (ImageView) headerView.findViewById(R.id.image);
// init universal image loader library
ImageUtil.initImageUtil(this);
ImageUtil.displayRoundImage(iv, "http://www.sample.com/0.jpg", null);
mDrawerList.addHeaderView(headerView);// Add header before adapter (for pre-KitKat)
mDrawerList.setAdapter(new DrawerSocialAdapter(this));
mDrawerList.setOnItemClickListener(new MainActivity.DrawerItemClickListener());
int color = ContextCompat.getColor(getApplicationContext(),R.color.material_grey_100);
color = Color.argb(0xCD, Color.red(color), Color.green(color),
Color.blue(color));
mDrawerList.setBackgroundColor(color);
mDrawerList.getLayoutParams().width = (int) getResources()
.getDimension(R.dimen.drawer_width_social);
mDrawerToggle = new ActionBarDrawerToggle(this, mDrawerLayout, toolbar,
R.string.drawer_open, R.string.drawer_close) {
public void onDrawerClosed(View view) {
getSupportActionBar().setTitle(mTitle);
invalidateOptionsMenu();
}
public void onDrawerOpened(View drawerView) {
getSupportActionBar().setTitle(mDrawerTitle);
invalidateOptionsMenu();
}
};
mDrawerLayout.addDrawerListener(mDrawerToggle);
if (savedInstanceState == null) {
// open drawer oncreate
//mDrawerLayout.openDrawer(mDrawerList);
}
修正方法は?
前もって感謝します。