【问题标题】:Styling TabLayout in Android在 Android 中设置 TabLayout 的样式
【发布时间】:2022-07-07 14:20:09
【问题描述】:

我有我应该在代码中实现的示例。分页之类的东西。我选择了 TabLayout。机械上一切正常。但它看起来不正确。 Picture of sample and my try????

下面是我所做的代码。对于圆圈,我制作了形状为“椭圆”和“state_selected”的简单可绘制选择器:

<com.google.android.material.tabs.TabLayout
        android:id="@+id/tabLayoutGeneration"
        android:layout_width="match_parent"
        android:layout_height="78sp"
        android:layout_marginTop="10sp"
        app:tabBackground="@drawable/selector_navigation_generator"

        app:tabIndicatorGravity="bottom"
        app:tabMaxWidth="41sp"
        app:tabTextColor="@color/white">

        <com.google.android.material.tabs.TabItem
            android:id="@+id/tabDate"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:text="1" />

        <com.google.android.material.tabs.TabItem
            android:id="@+id/tabCity"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:text="2" />

        <com.google.android.material.tabs.TabItem
            android:id="@+id/tabLocation"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:text="3" />
    </com.google.android.material.tabs.TabLayout> ```

【问题讨论】:

  • 你应该为你的自定义视图设计尝试这个 stepview 库; github.com/tatocaster/StepView
  • @BhoomikaPatel 看起来棒极了。但我认为有问题,它无法连接到我的项目。你用过吗?
  • 如果您在 Android Studio 中使用当前项目模板,如果您将 maven {...} 块放在自述文件指示的位置,则可能会导致问题。看看这里:stackoverflow.com/a/70989593.
  • @BhoomikaPatel 是的,我几个小时前读过这篇文章。所以我的“行家”位于屏幕截图所示的位置。

标签: android mobile layout styles android-tablayout


【解决方案1】:

感谢 Bhoomika 建议使用库并告诉我我需要的这个东西叫做“Step View”。来自 tatocaster 的图书馆现在无法使用,但我发现了很多其他的图书馆。所以对我最有用的是https://github.com/shuhart/StepView

【讨论】:

    猜你喜欢
    • 2015-09-23
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2010-11-11
    • 2018-11-27
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多