100字范文,内容丰富有趣,生活中的好帮手!
100字范文 > Android中导航栏之自定义导航布局

Android中导航栏之自定义导航布局

时间:2018-10-07 08:01:55

相关推荐

Android中导航栏之自定义导航布局

Toolbar系列文章导航

Android中导航栏之Toolbar的使用

Android中导航栏之溢出菜单OverflowMenu

Android中导航栏之搜索框SearchView

Android中导航栏之自定义导航布局

Android中导航栏之标签导航暨TabLayout用法

之前我们说了Toolbar的各种用法,但此时我们就有小伙伴发出灵魂拷问了:太丑了,真的太丑了。哈?好吧,既然要求这么高,那么我们只能放大招了,开始自定义布局。其实很简单,就是在Toolbar的容器中加入我们自己的布局就可以了,示例代码如下:

<?xml version="1.0" encoding="utf-8"?><LinearLayout xmlns:android="/apk/res/android"xmlns:app="/apk/res-auto"android:layout_width="match_parent"android:layout_height="match_parent"android:orientation="vertical"><androidx.appcompat.widget.Toolbarapp:contentInsetStartWithNavigation="0dp"android:layout_width="match_parent"android:layout_height="wrap_content"android:id="@+id/tl_head"><RelativeLayoutandroid:layout_width="match_parent"android:layout_height="wrap_content"><TextViewandroid:layout_width="wrap_content"android:layout_height="wrap_content"android:text="中间"android:layout_centerInParent="true"/><TextViewandroid:layout_width="wrap_content"android:layout_height="wrap_content"android:text="左边"/><TextViewandroid:layout_width="wrap_content"android:layout_height="wrap_content"android:layout_alignParentRight="true"android:text="右边"/></RelativeLayout></androidx.appcompat.widget.Toolbar></LinearLayout>

这样我们就在Toolbar中定义了三个文字。我们还可以定义如日期选择器等功能,或者定制我们自己的标题。也可以定义右侧的图标按钮等。

本内容不代表本网观点和政治立场,如有侵犯你的权益请联系我们处理。
网友评论
网友评论仅供其表达个人看法,并不表明网站立场。