per ottenere il controllo totale di dimensioni mi consiglia di utilizzare una visualizzazione personalizzata per rendere la scheda.
Innanzitutto creare un nuovo layout - denominata "my_custom_tab" per questo esempio
<?xml version="1.0" encoding="utf-8"?>
<!--Change the width, height, scaleType to whatever you like-->
<ImageView
xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:scaleType="fitCenter"
android:id="@+id/icon"
android:layout_gravity="center_horizontal"
android:src="@mipmap/ic_launcher"/>
Ora nel codice impostare l'immagine personalizzata
private void setUpTabs (ViewPager viewPager) {
TabLayout tabs = (TabLayout) findViewById(R.id.tabs);
if (tabs != null) {
tabs.setupWithViewPager(viewPager);
int tabCount = tabAdapter.getCount(); //Assuming you have already somewhere set the adapter for the ViewPager
for (int i = 0; i < tabCount; i++) {
TabLayout.Tab tab = tabs.getTabAt(i);
if (tab != null){
ImageView myCustomIcon = (ImageView) LayoutInflater.from(tabs.getContext()).inflate(R.layout.my_custom_tab, null);
/*Here is where to set image if doing it dynamically
myCustomIcon.setImageBitmap(bitmap);
*/
tab.setCustomView(myCustomIcon);
}
}
}
}
cambiare altezza e larghezza da xml .. –
prova ridimensionamento icona utilizzando editor –
imposta l'altezza di tablayout per aumentare la dimensione dell'icona –