我遇到的问题是我在SlidingTabLayout中有一种填充。
这是截图
如您所见,背景来自底部的滑块。最近,使用pagertabstrip库,我没有看到,但现在我尝试了新的com.example.android.common.view.SlidingTabLayout它肯定在那里。如何删除这个填充?
由于
和hiere是xml:
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="vertical"
android:layout_width="match_parent"
android:layout_height="match_parent">
<com.example.android.common.view.SlidingTabLayout
android:id="@+id/lib_tabs"
android:layout_width="match_parent"
android:layout_height="?attr/actionBarSize"
android:background="@android:color/holo_green_light"
/>
<android.support.v4.view.ViewPager
android:id="@+id/lib_pager"
android:layout_width="match_parent"
android:layout_height="0dp"
android:layout_weight="1" />
</LinearLayout>
式
<!-- Base application theme. -->
<style name="AppTheme" parent="Theme.AppCompat.Light.DarkActionBar">
<!-- Customize your theme here. -->
<item name="windowActionBar">false</item>
<item name="colorPrimary">@color/my_action_bar_color</item>
</style>
<style name="ToolBarStyle" parent="">
<item name="popupTheme">@style/ThemeOverlay.AppCompat.Light</item>
<item name="theme">@style/ThemeOverlay.AppCompat.Dark.ActionBar</item>
</style>
片段
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container,
Bundle savedInstanceState) {
View view = inflater.inflate(R.layout.lib_tabs, null);
mViewPager = (ViewPager) view.findViewById(R.id.lib_pager);
mViewPager.setAdapter(new CustomPagerAdapter(this.getFragmentManager()));
mSlidingTabLayout = (SlidingTabLayout) view.findViewById(R.id.lib_tabs);
mSlidingTabLayout.setViewPager(mViewPager);
return view;
}
public class CustomPagerAdapter extends FragmentPagerAdapter {
private final String[] TITLES = {"Categories", "Home", "Top"};
public CustomPagerAdapter(FragmentManager fm) {
super(fm);
}
@Override
public CharSequence getPageTitle(int position) {
return TITLES[position];
}
@Override
public int getCount() {
return TITLES.length;
}
@Override
public android.support.v4.app.Fragment getItem(int position) {
return LibSimpleInstanceableFragment.newInstance();
}
}
答案 0 :(得分:6)
distributeEvenly
为true
时会发生这种情况。只需评论
lp.width = 0;
在populateTabStrip()
课程的SlidingTabLayout.java
方法中,您的问题就会得到解决。
答案 1 :(得分:1)
将高度更改为wrap_content:
<com.example.android.common.view.SlidingTabLayout
android:id="@+id/lib_tabs"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="@android:color/holo_green_light"
/>
答案 2 :(得分:0)
根据您的需要编辑以下值
private static final int DEFAULT_BOTTOM_BORDER_THICKNESS_DIPS = 0;
private static final byte DEFAULT_BOTTOM_BORDER_COLOR_ALPHA = 0x26;
你欠我一个酒!
答案 3 :(得分:0)
删除SlidingTabLayout上的minHeight