I followed this tutorial . I have made simple change that shows TabLayout at bottom of screen.
activity_main.xml
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical">
<android.support.v4.view.ViewPager
android:id="@+id/viewpager_landing"
android:layout_width="match_parent"
android:layout_height="0px"
android:layout_weight="1"
android:background="@android:color/white" />
<android.support.design.widget.TabLayout
android:id="@+id/sliding_tabs_landing"
style="@style/MyCustomTabLayout"
android:layout_width="match_parent"
android:layout_height="wrap_content"
app:tabMode="fixed" />
</LinearLayout>
Problem:-
TabIndicator
is showing at bottom of screen working well,Now I want to show that TabIndicator
at Top of Tabs rather than bottom. Using custom layout we can do that as mentioned in tutorial but is there any xml attribute that will show TabIndicator
at top ?
This worked for me:
LinearLayout tabs = ((LinearLayout) tabLayout.getChildAt(0));
for (int position = 0; position < tabs.getChildCount(); position++) {
LinearLayout item = ((LinearLayout) tabs.getChildAt(position));
item.setRotationX(180);
}
将此行添加到XML中的TabLayout
app:tabIndicatorGravity="top"
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.