【问题标题】:Android - ViewPager: Tabs with fixed positionsAndroid - ViewPager:固定位置的标签
【发布时间】:2014-03-03 21:18:47
【问题描述】:

我正在使用 ViewPager 创建选项卡布局。它工作正常,但我想稍微改变它的行为。当我滑动到一个新标签时,它的标题被移动到宽度的中心,迫使其他标签的标题看起来有点压缩。我希望所有标签标题都保持在固定位置。我尝试稍微修改布局,但我没有得到任何地方......我该如何实现?

<LinearLayout
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:orientation="vertical"
android:layout_width="fill_parent"
android:layout_height="fill_parent">

<com.viewpagerindicator.TitlePageIndicator
    android:id="@+id/indicator"
    android:padding="10dip"
    android:layout_height="wrap_content"
    android:layout_width="fill_parent"
    android:background="#000000"
    android:textColor="#2FB3E3"
    app:footerColor="#2FB3E3"
    app:footerLineHeight="1dp"
    app:footerIndicatorHeight="3dp"
    app:footerIndicatorStyle="underline"
    app:selectedColor="#FFFFFF"
    app:selectedBold="true"
    />
<com.bill.deuterh.NoSwipeViewPager
    android:id="@+id/pager"
    android:layout_width="fill_parent"
    android:layout_height="0dp"
    android:layout_weight="1"
    />

</LinearLayout>

【问题讨论】:

  • 您可能需要使用TabPageIndicator 而不是TitlePageIndicator...
  • 您好,您找到解决方案了吗?使用 TabPageIndicator 无济于事

标签: android android-viewpager viewpagerindicator


【解决方案1】:

为什么不使用片段而不是在 xml 中声明所有?在java文件中可以更灵活,片段可以复用..

有关使用片段的完整示例,您可以在此处阅读:http://developer.android.com/reference/android/support/v4/view/ViewPager.html

【讨论】:

  • 我不明白这有什么关系。我已经为每个选项卡活动使用片段。我还能如何让它发挥作用?我的问题不在于活动。它与标题在活动上方显示的方式有关
猜你喜欢
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2020-10-30
  • 2016-05-04
  • 2017-02-13
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多