Android 智能标签布局如何使标签等距居中
Android Smart tab layout how to have equally spaced tabs with centering
我正在尝试使用 SmartTabLayout 库实现与此类似的布局:
https://blog.nus.edu.sg/mobileixd/files/2015/02/1-1g3mmmu.png
我可以添加等间距的选项卡图标,但它们都靠近屏幕中央放置。或者,我可以有等间距的选项卡,但中间没有选定的选项卡。
我如何实现两者的结合?
我试图用一定厚度的透明分隔器来实现这一点,但我无法达到所需的结果。
如何实现这种布局,选中的选项卡位于中间,另外两个位于屏幕的两端?
我为此使用以下布局:
<com.abc.resfree.ui.widgets.SmartTabLayout
android:id="@+id/tab_layout"
android:layout_width="match_parent"
android:layout_height="56dp"
app:stl_dividerColor="@android:color/transparent"
app:stl_dividerThickness="30dp"
app:stl_indicatorColor="@color/transparent"
app:stl_indicatorThickness="0dp"
app:stl_underlineColor="@color/transparent"
app:stl_underlineThickness="0dp"
app:stl_indicatorAlwaysInCenter="true"
/>
没有使用 SmartTabLayout 库,但我正在使用 android 支持库提供的 TabLayout。你可以试试
app:tabMode="scrollable"
app:tabGravity="fill"
这些属性(它们当然与支持库一起工作!)。你可能想试试。
我正在尝试使用 SmartTabLayout 库实现与此类似的布局: https://blog.nus.edu.sg/mobileixd/files/2015/02/1-1g3mmmu.png
我可以添加等间距的选项卡图标,但它们都靠近屏幕中央放置。或者,我可以有等间距的选项卡,但中间没有选定的选项卡。 我如何实现两者的结合? 我试图用一定厚度的透明分隔器来实现这一点,但我无法达到所需的结果。
如何实现这种布局,选中的选项卡位于中间,另外两个位于屏幕的两端?
我为此使用以下布局:
<com.abc.resfree.ui.widgets.SmartTabLayout
android:id="@+id/tab_layout"
android:layout_width="match_parent"
android:layout_height="56dp"
app:stl_dividerColor="@android:color/transparent"
app:stl_dividerThickness="30dp"
app:stl_indicatorColor="@color/transparent"
app:stl_indicatorThickness="0dp"
app:stl_underlineColor="@color/transparent"
app:stl_underlineThickness="0dp"
app:stl_indicatorAlwaysInCenter="true"
/>
没有使用 SmartTabLayout 库,但我正在使用 android 支持库提供的 TabLayout。你可以试试
app:tabMode="scrollable"
app:tabGravity="fill"
这些属性(它们当然与支持库一起工作!)。你可能想试试。