Android Bottombar。Bottomnavigationview
・テンプレートから始められる。
・既存のプロジェクトに追加する場合は、
New → Activity → Bottom Navigation Activity
・Modelファイルは、「ui」フォルダの中にある。
Fragmentのほうに、onViewCreatedで、作っていく。fragmentなので。Modelでも良いけど、よくわからない
@Override
public void onViewCreated(View view, Bundle savedInstanceState) {
super.onViewCreated(view, savedInstanceState);
}
viewのテキストは、こんな感じ
final TextView textView = view.findViewById(R.id.statustextview);
と思ったけれど、Activityでなくても良いのかも。
Step1: menu.xmlを作成する
Step2: layout.xmlを作成する
Step3: listenerをセットする。
色の変更
https://qrunch.net/@meww6m/entries/J3UJ5tkPSL4phy3y
1. resのなかにcolorディレクトリを作る
2. そのcolorディレクトリの中にbuttom_navigation.xmlをつくり、次の内容を記載する
res/color/buttom_navigation.xml
<?xml version="1.0" encoding="utf-8"?>
<selector xmlns:android="http://schemas.android.com/apk/res/android">
<item android:state_checked="true" android:color="#FFF" />
<item android:state_pressed="true" android:color="#FFF" />
<item android:color="#969696" />
</selector>
3. buttomnavigationviewの方に指定をする
res/layout/main.xml
<android.support.design.widget.BottomNavigationView
android:id="@+id/navigation"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_gravity="bottom"
android:background="?android:attr/windowBackground"
app:itemBackground="@color/themecolor"
app:itemIconTint="@color/buttom_navigation"
app:itemTextColor="@color/buttom_navigation"
app:menu="@menu/navigation" />
文字を常に表示
layoutのxmlファイルで、BottomNavigationViewに
app:labelVisibilityMode="labeled"