[英]Not able to fix PagerTitleStrip in android
The PagerTitleStrip is overflowing. PagerTitleStrip正在溢出。 I am not able to see all the title at a time.
我一次看不到所有标题。 Not able to make out what i am missing here.
无法找出我在这里想念的东西。 I have attached the screenshots.
我已附上屏幕截图。
Also how do i add material UI theme to these tabs. 另外,我如何向这些选项卡添加重要的UI主题。 which library is required and how to i apply the theme for the tab or for the entire application
哪个库是必需的,以及如何将主题应用于选项卡或整个应用程序
My adapter code 我的适配器代码
public class MyAdapter extends FragmentPagerAdapter
{
int totalFragments = 3;
public MyAdapter(FragmentManager fm) {
super(fm);
}
@Override
public Fragment getItem(int position) {
return MyFragment.newInstance(position);
}
@Override
public int getCount() {
return totalFragments;
}
@Override
public CharSequence getPageTitle(int position) {
switch (position) {
case 0:
return "Tab One";
case 1:
return "Tab Two";
case 2:
return "Tab Three";
}
return null;
}
}
Layout file: 布局文件:
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:orientation="vertical" >
<LinearLayout
android:layout_width="match_parent"
android:layout_height="0dp"
android:layout_weight="0.3"
android:orientation="vertical" >
</LinearLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="0dp"
android:layout_weight="0.7"
android:orientation="vertical" >
<android.support.v4.view.ViewPager
xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/pager"
android:layout_width="match_parent"
android:layout_height="match_parent" >
<android.support.v4.view.PagerTitleStrip
android:id="@+id/pager_title_strip"
android:scrollbarSize="200dp"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_gravity="top"
android:background="#33b5e5"
android:paddingBottom="4dp"
android:paddingTop="4dp"
android:textColor="#fff" />
</android.support.v4.view.ViewPager>
</LinearLayout>
</LinearLayout>
First, where you have used fill_parent
, replace those with match_parent
, since filling is deprecated. 首先,在不使用
fill_parent
地方,请使用fill_parent
,将其替换为match_parent
。
Second, the common settings for ViewPager
size are 其次,
ViewPager
大小的常用设置是
android:layout_width="match_parent"
android:layout_height="0px"
and possibly 并且可能
android:layout_weight="1"
After these, for your PagerTitleStrip
, try 在这些之后,为您的
PagerTitleStrip
尝试
android:layout_width="wrap_content"
Third, The material way of designing tabbed vies is with TabLayout
, which Google has some tutorials and examples for. 第三,设计选项卡式
TabLayout
的实质方法是使用TabLayout
,Google为其提供了一些教程和示例。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.