gpt4 book ai didi

android - 如何保证我的操作栏选项卡在所有屏幕尺寸下始终可见?

转载 作者:行者123 更新时间:2023-11-29 21:43:56 24 4
gpt4 key购买 nike

我正在尝试复制 github 应用程序中的选项卡: enter image description here

但是,我的标签太长了:

enter image description here

我知道我可以为一个选项卡设置自定义 View ,我想我可以随意调整 View 、样式、文本大小等以使所有四个选项卡都适合。

但是,如果我这样做,我能保证所有选项卡都适合屏幕较小的用户吗?我如何确保标签永远不会离开屏幕?

最佳答案

我认为您不能保证标签不会消失。通过使用四个固定选项卡,您做出了有意识的设计决定。当没有足够的空间时,选项卡会变成可滚动的。

根据这个doc :

Fixed tabs are displayed with equal width, based on the width of the widest tab label. If there is insufficient room to display all tabs, the tab labels themselves will be scrollable. For this reason, fixed tabs are best suited for displaying 3 or fewer tabs.

我的建议是,如果您的用户不会太不直观,就放弃文本并改用图标。为您的选项卡定义一个 XML 资源,从您通常创建图标的任何地方创建一些图标。

<?xml version="1.0" encoding="utf-8"?>
<selector xmlns:android="http://schemas.android.com/apk/res/android">
<item android:drawable="@drawable/my_icon_focused"
android:state_selected="true" />
<item android:drawable="@drawable/my_icon" />
</selector>

关于android - 如何保证我的操作栏选项卡在所有屏幕尺寸下始终可见?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/16380197/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com