0

I used BottomNavigationbar in my android app. When I run on a tablet, it shows very small icons in bottomnavigationbar. I want to increase the size for tablets.

I tried to put different sizes of icons in drawable folders but the problem is still there.

main_activity.xml

<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"
android:background="@color/backgroundGray"
tools:context="com.shakeel.board.MainActivity">

<FrameLayout
    android:id="@+id/fragments_container"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:layout_above="@+id/bottom_nav_bar">
</FrameLayout>

<android.support.design.widget.BottomNavigationView
    android:id="@+id/bottom_nav_bar"
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    android:layout_alignParentBottom="true"
    app:menu="@menu/bottom_navigation_menu"
    android:padding="5dp"
    android:background="@color/white">
</android.support.design.widget.BottomNavigationView>

bottom_navigation_menu.xml

<item android:id="@+id/nav_home"
    android:title="Home"
    android:icon="@drawable/home"/>

<item android:id="@+id/nav_favorites"
    android:title="Favorite"
    android:icon="@drawable/ic_favorite_red_24dp"/>

<item android:id="@+id/nav_shop"
    android:title="Shop"
    android:icon="@drawable/ic_shopping_basket_black_24dp"/>

<item android:id="@+id/nav_setting"
    android:title="Setting"
    android:icon="@drawable/ic_settings_black_24dp"/>

MainActivity.class

public class MainActivity extends AppCompatActivity {

BottomNavigationView bootomNavigation;

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_main);

    bootomNavigation = findViewById(R.id.bottom_nav_bar);
    BottomNavigationViewHelper.removeShiftMode(bootomNavigation);
    getSupportFragmentManager().beginTransaction().replace(R.id.fragments_container, new HomeFragment()).commit();
    bootomNavigation.setOnNavigationItemSelectedListener(new BottomNavigationView.OnNavigationItemSelectedListener() {
        @Override
        public boolean onNavigationItemSelected(@NonNull MenuItem item) {
            Fragment selectedFragment = null;
            switch (item.getItemId()){
                case R.id.nav_home:
                    selectedFragment = new HomeFragment();
                    break;

                case R.id.nav_favorites:
                    selectedFragment = new FavoritesFragment();
                    break;

                case R.id.nav_shop:
                    selectedFragment = new ShopFragment();
                    break;

                case R.id.nav_setting:
                    selectedFragment = new SettingFragment();
                    break;
            }
            getSupportFragmentManager().beginTransaction().replace(R.id.fragments_container, selectedFragment).commit();
            return true;
        }
    });
}
}
Tamir Abutbul
  • 7,301
  • 7
  • 25
  • 53
Qazi Hassan
  • 35
  • 1
  • 7

1 Answers1

0

You can download your icons from the material design page, select your icons and then select the Android option (see image below) and you will get a set of the same icon in different sizes for different screen sizes.

enter image description here

Tamir Abutbul
  • 7,301
  • 7
  • 25
  • 53