Chris
Chris

Reputation: 6311

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.

Upvotes: 3

Views: 4233

Answers (1)

tiny sunlight
tiny sunlight

Reputation: 6251

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.

Upvotes: 3

Related Questions