我如何在 android 中制作这样的自定义视图

How could i make a custom view like this in android

需要自定义视图


您好,我正在尝试设计一个像上面那样的自定义 tablayout。 我试过使用带有三边边框的自定义视图,但这与上面的不完全一样 image.Can 请任何人帮助...

到目前为止,我已经按照下图完成了,但这与预期的不完全一样。


在您的 style.xml 中为您的标签页创建新样式并添加如下内容

   <style name="MyCustomTabLayout" parent="Widget.Design.TabLayout">
        <item name="tabIndicatorColor">@android:color/white</item>
   <item name="tabBackground">@android:color/white</item>
</style>

并将此样式应用到您的 TabLayout 将解决您的问题

仅作记录,我使用 recyclerview 而不是 tablayout.Using 自定义视图和 recyclerview viewholder 为我提供了更多 flexibility.Feel 如果有人有更好的解决方案,请免费通知我。