LoginSignup
1
2

More than 5 years have passed since last update.

アイコンがシルエットにならない AHBottomNavigation を作った

Last updated at Posted at 2017-01-10

これはなにか

Before After
device-2017-01-10-105511.png device-2017-01-10-105606.png

AHBottomNavigation は指定したタブのアイコンが強制的にアイコンシルエットになりますが、タブのアイコンにオリジナルの画像そのままを表示できるようにしました。

ソースコード

https://github.com/yhirano/ahbottomnavigation/tree/cancel_tint_icon

インストール

allprojects {
    repositories {
        // ...
        maven { url 'https://jitpack.io' }
    }
}
dependencies {
    compile 'com.github.yhirano:ahbottomnavigation:2.0.6-p1'
}

使い方

AHBottomNavigationItem はオリジナルのコンストラクタを排し、Builderでインスタンスを作るように変更しました。
他の基本的な使い方はオリジナルの AHBottomNavigation と同じ。

AHBottomNavigationItem item1 =
    new AHBottomNavigationItem.Builder(R.string.tab_1, R.drawable.ic_maps_place)
        .setColorRes(R.color.color_tab_1)
        .setTintDrawableActive(false)    // タブがアクティブな際にアイコンをシルエットにしないようにする
        .setTintDrawableInactive(false)  // タブが非アクティブな際にアイコンをシルエットにしないようにする
        .build();

なお、 XMLリソースからのタブを作成する場合のタブのアイコンの非シルエット機能には対応していません。

1
2
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
1
2