问题
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.
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.
回答1:
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.
来源:https://stackoverflow.com/questions/34068329/android-how-can-i-change-icons-size-in-action-bar-tabs