如何在我的自定义选项卡上进行一些收尾工作(圆角边缘和水平分隔线)

编程入门 行业动态 更新时间:2024-10-26 02:36:42
本文介绍了如何在我的自定义选项卡上进行一些收尾工作(圆角边缘和水平分隔线)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

限时送ChatGPT账号..

这是我上一个问题的后续链接

This is a follow up to my last question Link

我想对标签的外观进行一些小的调整.我通过将视图传递给 setIndicator() 而不是 charSequence 和图标来完成此操作.

I wanted to make some small adjustments to the look of the tabs. I accomplished this by passing a view into setIndicator() instead of a charSequence and icon.

问题:现在我必须完全重新创建选项卡的外观(我只是想要一些小的更改).哦,好吧,我现在有一些可以正常工作的选项卡.

the problem: now I have to totally recreate the look and feel of the tabs (I just wanted some small changes). oh well, I've got some tabs working now that are ok.

基本上有两件事我似乎无法重现.

There are basically two things that I can't seem to recreate.

主要是:(1) 我不想在我的选项卡下(与所选选项卡颜色相同)像默认情况下那样有一个水平条.

the main one being:(1) I wan't a horizontal bar right under my tabs (same color as the selected tab) like the one that is there by default.

这是我的标签:

这里有一些来自 developer.android

另一个不太重要,但会非常好.(2) 如何使它们实际上看起来像标签而不是矩形(弯曲的边缘,如第二张图像).我认为这与我放入的分隔线有关.虽然我不是平面设计师,但他们是这些图像的任何好的资源.另外,我想以一种至少有一些希望将来不会破坏的方式来做.

The other is less important but would be really nice. (2) how to make them actually look like tabs instead of rectangles (curved edges, like in the second image). I assume this has to do with the divider I put in. I'm not a graphic designer though, are their any good resource for these images. also, I would like to do it in a way that has at least some hope of not breaking in the future.

任何人有任何建议(特别是对于 Q:1),我们将不胜感激.我曾希望加入一些填充,现在,学习制作自定义标签的 4 天时间.哈哈

anyone has any suggestions (especially for Q:1), that would be much appreciated. I had hoped to throw in a little padding, and now, 4 days of learning to make custom tabs. lol

推荐答案

我还没有完成所有工作,但如果其他人遇到了这个问题,这里是我学到的.

I haven't got it all working yet, but in case anyone else is having trouble with this, here is what I learned.

对于圆角 (2):在用于选项卡指示器背景的 drawable 中放置类似的内容.对我(可能还有大多数其他人)来说,这意味着将它嵌套在 'tab_selected.xml' 和 'tab_unselected.xml' 中的形状标签中

for rounded corners (2): put something like this in the drawable you use for your tab indicator background. for me (and probably most others) that means nesting it within the shape tag in both 'tab_selected.xml' and 'tab_unselected.xml'

<corners android:bottomLeftRadius="0dp"
         android:bottomRightRadius="0dp" 
         android:topLeftRadius="5dp"
         android:topRightRadius="5dp" />

注意:我认为在通用语言中我通常称之为标签"的东西在技术上被称为 android 上的标签指示器".

Note: What I would usually call a 'tab' in common language I believe is technically called a 'tab indicator' on android.

对于选项卡指示器下方的水平分隔线 (1):我对此仍然不太清楚,但我认为您可以 (1:a) 添加另一个形状标记到tab_unselected.xml"以绘制线条你指定.

For the horizontal divider below the tab indicators (1): I am a little less clear on this still, but I think you could (1:a) add another shape tag to 'tab_unselected.xml' that will draw the line you specify.

或者,我相信您可以 (1:b) 通过设置 tabWidget 的tabStripEnabled"、tabStripLeft"和tabStripRight"属性来指定要使用的可绘制对象.

alternatively, I believe you can (1:b) specify a drawable to use by setting 'tabStripEnabled', 'tabStripLeft', and 'tabStripRight' properties of the tabWidget.

不过这些对我来说不是很清楚.

Those are not so clear to me though.

好吧,我希望这可以帮助那些为此苦苦挣扎的人至少获得一些想法.

well, I hope that can help someone struggling with this to at least get some ideas.

这篇关于如何在我的自定义选项卡上进行一些收尾工作(圆角边缘和水平分隔线)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

更多推荐

[db:关键词]

本文发布于:2023-05-01 10:52:40,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1408874.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:收尾   自定义   卡上   选项   圆角

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!