Android: how do I change the icon size in the action bar tab?
•
Android
I created an action bar tab activity for the project. I used 3 tabs and added some icons. However, even if I download icons at the price of 48dp, they will be displayed in a smaller size
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 do I change the size of an icon? I also have a floatingactionbutton with the same problem. The icon in it is very small
resolvent:
Just add your own tab
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 has only two sizes: mini or normal, where iamge has a fixed size
The content of this article comes from the network collection of netizens. It is used as a learning reference. The copyright belongs to the original author.
THE END
二维码