Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Android: How can I change icons size in Action Bar Tabs?

I created an Action Bar Tabs activity for my project. I used 3 tabs and I added some icons. But the icons are shown in a small size, even if I downloaded them in 48dp.

enter image description here

My code is:

<android.support.design.widget.TabLayout
        android:id="@+id/tabs"
        android:layout_width="match_parent"
        android:layout_height="wrap_content" />

final private int[] tabIcons = {
        R.drawable.ic_photo_library,
        R.drawable.ic_chat,
        R.drawable.ic_people
};

private void setupTabsIcons() {

    tabLayout.getTabAt(0).setIcon(tabIcons[0]);
    tabLayout.getTabAt(1).setIcon(tabIcons[1]);
    tabLayout.getTabAt(2).setIcon(tabIcons[2]);

}

How could I change the size of the icons? I also have a FloatingActionButton with the same problem. The icon inside it is small.

like image 829
Chris Avatar asked Nov 27 '25 06:11

Chris


1 Answers

Just add Tab you self.

TabLayout layout = new TabLayout(TestActvt.this);
View view = getLayoutInflater().inflate(R.layout.custom,null);
view.findViewById(R.id.img).setImageResource(R.drawable.img);
TabLayout.Tab tab = layout.newTab().setCustomView(view);
layout.addTab(tab);

FloatingActionButton only has 2 size : mini or normal and Iamge in them has fixed size.

like image 123
tiny sunlight Avatar answered Nov 28 '25 21:11

tiny sunlight



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!