仿喜马拉雅app底部导航栏五个按钮-clipChildren属性
2018-03-27 10:08
260 查看
clipChildren属性
clipChildren属性表示是否限制子控件在该容器所在的范围内,clipChildren属性配合layout_gravity属性,可以用来设置多余部分的显示位置,我这里举一个简单的例子,比如喜马拉雅FM这个应用的首页:大家注意看这个应用底部导航栏中中间一个是要比另外四个高的,这种效果很多人就会想到使用一个RelativeLayout布局来实现,其实不用那么麻烦,这种效果一个clipChildren属性就能实现,示例Demo如下:
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:clipChildren="false"
tools:context="org.lenve.clipchildren.MainActivity">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="48dp"
android:layout_alignPar
4000
entBottom="true"
android:background="#03b9fc"
android:orientation="horizontal">
<ImageView
android:layout_width="0dp"
android:layout_height="match_parent"
android:layout_weight="1"
android:src="@mipmap/ic_launcher"/>
<ImageView
android:layout_width="0dp"
android:layout_height="match_parent"
android:layout_weight="1"
android:src="@mipmap/ic_launcher"/>
<ImageView
android:layout_width="0dp"
android:layout_height="72dp"
android:layout_gravity="bottom"
android:layout_weight="1"
android:src="@mipmap/ic_launcher"/>
<ImageView
android:layout_width="0dp"
android:layout_height="match_parent"
android:layout_weight="1"
android:src="@mipmap/ic_launcher"/>
<ImageView
android:layout_width="0dp"
android:layout_height="match_parent"
android:layout_weight="1"
android:src="@mipmap/ic_launcher"/>
</LinearLayout>
</RelativeLayout>
大家看只需要在根节点添加clipChildren属性,然后在第三个ImageView上添加layout_gravity属性即可,layout_gravity属性值为bottom表示控件大小超出后控件底部对齐。效果如下:
相关文章推荐
- 安卓 AppCompat 隐藏标题栏 保留底部导航栏
- 导航栏设置返回按钮为自定义的 button 这时候设置 button 的一些属性
- H5 App页面 绝对定位 软键盘弹出时顶起底部按钮
- andorid 屏蔽导航栏的近期APP列表按钮
- viewpager的setCurrentItem 底部导航栏点击按钮实现直接跳转,去掉滑动效果
- 安卓APP底部导航栏(有消息圆点指示器),实现fragment切换(eclipse)
- 使用WebElements定位多个相似的元素,比如页面中存在五个单选按钮,他们有相同的class属性,值为:myRadio,我们想对五个按钮循环操作,我们可以把它们全部取出来放到集合中,然后做循环操作
- 安卓底部导航栏菜单弹出属性动画
- Android App底部导航栏的另一种实现方式
- Android App应用底部导航栏实现的一种方式
- 底部导航栏中间加按钮的简单解决
- 超酷的计步器APP(一)——炫酷功能实现,自定义水波纹特效、自定义炫酷开始按钮、属性动画的综合体验
- appframework 不显示底部导航栏footer.
- 实现底部导航栏,包含显示未读数、提示小红点、动画等功能的底部页签导航栏按钮
- ios weibo 第二天 设置导航栏属性,添加加号按钮, 新特性
- 实现底部导航栏中间凸起,(点击中间凸出按钮弹出菜单)
- ImageView实现APP底部按钮切换页面
- iOS App开发中导航栏的创建及基本属性设置教程
- UI之导航栏属性、按钮及样式、属性传值
- 微信公众平台开发(91) 右上角按钮/底部导航栏/用户网络状态