国际惯例,首先甩手一张效果图
这个效果在我项目中没有用到,但是看了基友做的一个app有这个效果,感觉挺有趣。
就自己实现了一个玩了,其实起来非常简单,我不像盆友一样自定义一个底部,我是直接写了一个布局
首先了解一个属性
android:clipChildren="false"这个属性的大概意思:父控件不限制子类的的大小
我的实现方法就一个布局
<?xml version="1.0" encoding="utf-8"?> <RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="match_parent" android:layout_height="match_parent" android:clipChildren="false"> <View android:layout_width="match_parent" android:layout_height="1dp" android:background="#ccc" android:layout_above="@+id/ll_bottom" /> <LinearLayout android:clipChildren="false" android:id="@+id/ll_bottom" android:layout_width="match_parent" android:layout_height="60dp" android:orientation="horizontal" android:layout_alignParentBottom="true" android:layout_alignParentStart="true"> <RelativeLayout android:layout_width="0dp" android:layout_height="match_parent" android:layout_gravity="bottom" android:layout_weight="1"> <ImageView android:id="@+id/iv1" android:layout_width="wrap_content" android:layout_height="30dp" android:layout_centerInParent="true" android:src="@mipmap/head_one" /> <TextView android:textSize="10sp" android:layout_centerInParent="true" android:text="文本" android:layout_width="wrap_content" android:layout_height="18dp" android:layout_below="@+id/iv1"/> </RelativeLayout> <RelativeLayout android:layout_width="0dp" android:layout_height="match_parent" android:layout_gravity="bottom" android:layout_weight="1"> <ImageView android:id="@+id/iv2" android:layout_width="wrap_content" android:layout_height="30dp" android:layout_centerInParent="true" android:src="@mipmap/head_one" /> <TextView android:textSize="10sp" android:layout_centerInParent="true" android:text="文本" android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_below="@+id/iv2"/> </RelativeLayout> <RelativeLayout android:layout_width="100dp" android:layout_height="100dp" android:layout_gravity="bottom" android:layout_marginBottom="8dp"> <ImageView android:id="@+id/dd5" android:layout_width="90dp" android:layout_height="70dp" android:layout_centerInParent="true" android:src="@mipmap/circle" /> <TextView android:textSize="10sp" android:layout_centerInParent="true" android:text="文本" android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_below="@+id/dd5"/> </RelativeLayout> <RelativeLayout android:layout_width="0dp" android:layout_height="match_parent" android:layout_gravity="bottom" android:layout_weight="1"> <ImageView android:id="@+id/iv3" android:layout_width="wrap_content" android:layout_height="30dp" android:src="@mipmap/head_one" android:layout_centerVertical="true" android:layout_centerHorizontal="true" /> <TextView android:textSize="10sp" android:layout_centerInParent="true" android:text="文本" android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_below="@+id/iv3"/> </RelativeLayout> <RelativeLayout android:layout_width="0dp" android:layout_height="match_parent" android:layout_gravity="bottom" android:layout_weight="1"> <ImageView android:id="@+id/iv4" android:layout_width="wrap_content" android:layout_height="30dp" android:layout_centerInParent="true" android:src="@mipmap/head_one" /> <TextView android:textSize="10sp" android:layout_centerInParent="true" android:text="文本" android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_below="@+id/iv4"/> </RelativeLayout> </LinearLayout> </RelativeLayout>
代码中用到的两张图片