-2
こんにちは、私は試してみましたが、アイコンとテキストが表示されていないので、各タブのテキストの上にあるアイコンで画面の下にタブを表示します。あなたは私を助けてくださいすることができます事前のおかげでAndroidタブの下にある画面
こんにちは、私は試してみましたが、アイコンとテキストが表示されていないので、各タブのテキストの上にあるアイコンで画面の下にタブを表示します。あなたは私を助けてくださいすることができます事前のおかげでAndroidタブの下にある画面
あなたは[更新]
今すぐあなたの条件を達成するためにBottomNavigationViewをリリースグーグルBottomBar
を達成するために、ライブラリの下に使用することができます。 このクラスは、サポートデザインライブラリの一部です。 は、上記のレイアウトに含まbottom_navigation_main.xmlファイルを作成
あなたのXMLに
<android.support.design.widget.BottomNavigationView
android:id="@+id/bottom_navigation"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_alignParentBottom="true"
app:itemBackground="@color/colorPrimary"
app:itemIconTint="@color/white"
app:itemTextColor="@color/white"
app:menu="@menu/bottom_navigation_main" />
をレイアウトファイルを追加 compile ‘com.android.support:design:25.0.0’
Gradleの依存関係を追加します。
<?xml version="1.0" encoding="utf-8"?>
<menu xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto">
<item
android:id="@+id/action_favorites"
android:enabled="true"
android:icon="@drawable/ic_favorite_white_24dp"
android:title="@string/text_favorites"
app:showAsAction="ifRoom" />
<item
android:id="@+id/action_schedules"
android:enabled="true"
android:icon="@drawable/ic_access_time_white_24dp"
android:title="@string/text_schedules"
app:showAsAction="ifRoom" />
<item
android:id="@+id/action_music"
android:enabled="true"
android:icon="@drawable/ic_audiotrack_white_24dp"
android:title="@string/text_music"
app:showAsAction="ifRoom" />
</menu>
し、最終的に
BottomNavigationView bottomNavigationView = (BottomNavigationView)
findViewById(R.id.bottom_navigation);
bottomNavigationView.setOnNavigationItemSelectedListener(
new BottomNavigationView.OnNavigationItemSelectedListener() {
@Override
public boolean onNavigationItemSelected(@NonNull MenuItem item) {
switch (item.getItemId()) {
case R.id.action_favorites:
break;
case R.id.action_schedules:
break;
case R.id.action_music:
break;
}
return false;
}
});
以下のようなJavaクラスでこのレイアウトを使用しますが、これまでにしようとしているすべてのものを投稿してください! – Shrikant
私はそれがタブではないと思います。私はちょうどメニューです。 –
マニフェストに 'android:uiOptions =" splitActionBarWhenNarrow "を追加するだけです。これを見てください:http://stackoverflow.com/a/18944930/5241603 –