c# - 如何制作自定义标签页?(底部圆角框)
解决方案
安卓:
shape_indicator_radius.xml
在drawable文件夹中添加:
<?xml version="1.0" encoding="utf-8" ?>
<shape xmlns:android="http://schemas.android.com/apk/res/android"
android:shape="rectangle" >
<corners android:bottomRightRadius="50dp" android:bottomLeftRadius="50dp"/>
<solid
android:color="@android:color/black"/>
</shape>
在 Tabbar.xml 中设置背景:
<?xml version="1.0" encoding="utf-8"?>
<android.support.design.widget.TabLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="@drawable/shape_indicator_radius">
</android.support.design.widget.TabLayout>
在 MainActivity 中,设置TabLayoutResource
OnCreate 方法。
TabLayoutResource = Resource.Layout.Tabbar;
IOS:
您可以使用自定义渲染器来做到这一点。
[assembly:ExportRenderer(typeof(TabbedPage),typeof(MyCustomRenderer))]
namespace App4.iOS
{
class MyCustomRenderer: TabbedRenderer
{
public override void ViewDidLoad()
{
base.ViewDidLoad();
this.TabBar.Layer.MasksToBounds = true;
this.TabBar.Translucent = true;
this.TabBar.BarStyle = UIBarStyle.Black;
this.TabBar.Layer.CornerRadius = 50;
this.TabBar.Layer.MaskedCorners =
CoreAnimation.CACornerMask.MaxXMinYCorner |
CoreAnimation.CACornerMask.MinXMinYCorner;
}
}
}
推荐阅读
- javascript - 从 javascript/typescript 中的类返回错误
- c# - 从 Azure CosmosDB 获取数据库
- flutter - Theme.of(context) 未传递给 simpleDialog
- java - 使用 PDFbox 绘制饼图
- c# - 使用 Dapper 将大数组插入已声明的 SQL Server 表中
- r - dplyr 对数据框和数据库的工作方式不同 - 如何解决?
- python - 有没有办法在 Python 中使这个“for循环”更干净?
- javascript - Rails - 后退按钮复制元素
- android - 如何使用开关创建指纹锁以启用/禁用锁定
- render - 删除对象渲染