废话不多说,直接上代码:
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="match_parent" android:layout_height="match_parent" android:clipChildren="false"><ImageViewandroid:layout_width="match_parent"android:layout_height="match_parent"android:layout_marginBottom="60dp"android:background="@mipmap/www" /> <LinearLayoutandroid:id="@+id/ll_bottom"android:layout_width="match_parent"android:layout_height="60dp"android:layout_alignParentBottom="true"android:background="#F8549D"android:elevation="10dp"android:orientation="horizontal"> <RelativeLayout android:layout_width="0dp" android:layout_height="match_parent" android:layout_gravity="bottom" android:layout_weight="1"><ImageViewandroid:layout_width="wrap_content"android:layout_height="wrap_content"android:layout_centerInParent="true"android:src="@mipmap/ic_launcher" /> </RelativeLayout> <RelativeLayout android:layout_width="0dp" android:layout_height="match_parent" android:layout_gravity="bottom" android:layout_weight="1"><ImageViewandroid:layout_width="wrap_content"android:layout_height="wrap_content"android:layout_centerInParent="true"android:src="@mipmap/ic_launcher" /> </RelativeLayout> <RelativeLayout android:layout_width="70dp" android:layout_height="70dp" android:layout_gravity="bottom" android:background="@drawable/bottom_bg_shape"><ImageViewandroid:layout_width="30dp"android:layout_height="30dp"android:layout_centerInParent="true"android:src="@mipmap/icon_go" /> </RelativeLayout><RelativeLayout android:layout_width="0dp" android:layout_height="match_parent" android:layout_gravity="bottom" android:layout_weight="1"><ImageViewandroid:layout_width="wrap_content"android:layout_height="wrap_content"android:layout_centerInParent="true"android:src="@mipmap/ic_launcher" /> </RelativeLayout> <RelativeLayout android:layout_width="0dp" android:layout_height="match_parent" android:layout_gravity="bottom" android:layout_weight="1"><ImageViewandroid:layout_width="wrap_content"android:layout_height="wrap_content"android:layout_centerInParent="true"android:src="@mipmap/ic_launcher" /> </RelativeLayout> </LinearLayout> </RelativeLayout>这张图呢是我刚刚做的,效果是参考了酷狗音乐播放器来完成的,我想说明重点在底部的导航栏:如图
再来一张反效果预览图:
如何使得蓝色圆形的播放键的显示越过粉色的范围。当然经过合理的布局是可以达到这样的效果的,但是却有更简单的方法。也就是在根布局的属性中加入一个来自Android自身提供的属性:
android:clipChildren="false"属性解释和说明: