Closed vipulyaara closed 9 years ago
HI, @vipulyaara
It works :) Without using DistributeEvenly, to specify the weight in a custom layout
smartTabLayout.setDistributeEvenly(false);
smartTabLayout.setCustomTabView(new SmartTabLayout.TabProvider() {
@Override
public View createTabView(ViewGroup container, int position, PagerAdapter adapter) {
View view;
switch (position) {
case 0:
view = inflater.inflate(R.layout.custom_tab_icon, container, false);
break;
case 1:
view = inflater.inflate(R.layout.custom_tab_text, container, false);
break;
case 2:
view = inflater.inflate(R.layout.custom_tab_icon, container, false);
break;
default:
throw new IllegalStateException("Invalid position: " + position);
}
return view;
}
});
smartTabLayout.setViewPager(...);
layout/custom_tab_icon.xml
<?xml version="1.0" encoding="utf-8"?>
<ImageView
xmlns:android="http://schemas.android.com/apk/res/android"
...
android:layout_width="0dp"
android:layout_height="match_parent"
android:layout_weight="1"
...
/>
layout/custom_tab_text.xml
<?xml version="1.0" encoding="utf-8"?>
<TextView
xmlns:android="http://schemas.android.com/apk/res/android"
...
android:layout_width="0dp"
android:layout_height="match_parent"
android:layout_weight="2"
...
/>
Great. It works. Thanks.
Hi. The view is very very flexible and I have used it for some very unique combinations. I wonder if I can make tabs of different sizes, while still filling up the screen.
I want 3 tabs. First and last of them are icons, and second is a long text. So I want to provide secondtab twice as weight of first and third. Currently it looks like the one in picture.