0
A
答えて
0
あなたは、下部のナビゲーションタブを使用して効果のようなものを得ることができます。このコードを試してみてください あなたは依存関係ここ
compile ‘com.android.support:design:25.0.0’
にこの行を追加する必要があり、それは下部のナビゲーションタブのあなたに
の支援を期待することはMainActivity.Java
パブリッククラスMainActivityがAppCompatActivityを拡張{ プライベートBottomBar mBottomBarです;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
// Notice how you don't use the setContentView method here! Just
// pass your layout to bottom bar, it will be taken care of.
// Everything will be just like you're used to.
mBottomBar = BottomBar.bind(this, R.layout.activity_main,
savedInstanceState);
mBottomBar.setItems(
new BottomBarTab(R.drawable.ic_recents, "Recents"),
new BottomBarTab(R.drawable.ic_favorites, "Favorites"),
new BottomBarTab(R.drawable.ic_nearby, "Nearby"),
new BottomBarTab(R.drawable.ic_friends, "Friends")
);
mBottomBar.setOnItemSelectedListener(new OnTabSelectedListener() {
@Override
public void onItemSelected(final int position) {
// the user selected a new tab
}
});
}
@Override
protected void onSaveInstanceState(Bundle outState) {
super.onSaveInstanceState(outState);
mBottomBar.onSaveInstanceState(outState);
}
}
Design.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"
android:layout_width="match_parent"
android:layout_height="match_parent">
<!-- Content Container -->
<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" />
</RelativeLayout>
Menu.xml
<?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>
<?xml version="1.0" encoding="utf-8"?>
<selector xmlns:android="http://schemas.android.com/apk/res/android">
<item android:color="@color/white" android:state_enabled="true" />
<item android:color="@color/colorPrimaryDark" android:state_enabled="false" />
</selector>
この
を使用してイベントをクリックしてハンドルの状態をクリックして有効/無効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;
}
});
0
効果マップが付いているあなたの描画可能なフォルダdrop_shadow.xmlに
<?xml version="1.0" encoding="utf-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android">
<gradient
android:startColor="#404040"
android:endColor="#F1F1F1"
android:angle="270"
>
</gradient>
</shape>
関連する問題
- 1. ネットワークコールを行うExcel UDF:パフォーマンスを向上させる方法
- 2. ページブレイクを上向きにする方法
- 3. ハイチャートパフォーマンス向上方法?
- 4. android-リストビューを上向きにする
- 5. androidのビューページのパフォーマンスを向上させる方法
- 6. AndroidでWebviewのパフォーマンスを向上させる方法は?
- 7. 子ビューナビゲーションの前に横向きの向きを扱う方法
- 8. Androidのドロップダウンスピナーにシャドウを追加する方法
- 9. Xamarin AndroidでSPPスループットを向上させる方法は?
- 10. シャドウDOM:シャドウDOMとは何かを編集する方法
- 11. BottomSheetのようなビューを上向きまたは下向きにコーディングする方法
- 12. 配列上で双方向データバインディングを行うことができません
- 13. は上向き
- 14. は上向き
- 15. Android/iPhoneウェブアプリの画面の向きを制御する方法
- 16. Androidデバイスの画面の向きをグローバルにロックする方法
- 17. Androidの画面の向きを検出する方法
- 18. Android画面の向き:横向き
- 19. HQLパフォーマンスを向上させる方法
- 20. イテレータで下向きの反復を行ううまくいく方法
- 21. データフレーム上の集計を行う方法
- 22. Androidレイアウトの向き
- 23. Vue.js 2のカスタムディレクティブで双方向バインディングを行う方法は?
- 24. ランダムなピクセルとランダムな方向のページスクロールを行う方法
- 25. three.js - パーティクルを常に上向きにする方法
- 26. Androidの力の向きの一方向にのみ
- 27. シャドウをブートストラップにオーバーレイする方法は?
- 28. ネットワーク上でMYSQLのパフォーマンスを向上させる方法
- 29. Androidタッチイベントの方向
- 30. Androidのアルファフェード方向
を追加するレイアウトに
をビューを追加します。 – FanMingYi