有个需求要实现底部的导航栏,但是图片是要凸起的,超越父控件的。。。原本想用radiobutton实现的,然后发现设置图片的时候无法设置准确大小和方向,而且代码动态设置的话,感觉也有点烦。。。所以直接5个布局,写死,然后自己手动换图片和文字颜色好了。。。先上效果图。。。
每个图片的大小也是不同的,这种布局方式出现的问题是,图片要超过父布局,这个时候就要用到clipChildren = false,默认是true就无法超过父布局。。。。
下面是activity的xml文件代码
<android.support.v4.widget.DrawerLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
xmlns:fresco="http://schemas.android.com/apk/res-auto"
xmlns:tl="http://schemas.android.com/apk/res-auto"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:id="@+id/main_drwaer_layout"
android:orientation="vertical">
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:clipChildren="false"
>
<com.gogosu.gogosuandroid.util.NonScrollableViewPager
android:id="@+id/fl_container"
android:layout_width="match_parent"
android:layout_marginBottom="54dp"
android:layout_height="match_parent"
/>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="54dp"
android:layout_alignParentBottom="true"
android:background="@color/white"
android:orientation="horizontal"
android:clipChildren="false"
>
<RelativeLayout
android:id="@+id/rl_home"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_weight="1"
android:clipChildren="false"
>
<TextView
android:id="@+id/tv_home"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="首页"
style="@style/HomeNavigateTextStyle"
/>
<ImageView
android:id="@+id/iv_navi_home"
android:layout_width="35dp"
android:layout_height="35dp"
android:background="@drawable/selector_navi_home"
android:layout_above="@id/tv_home"
android:layout_centerHorizontal="true"
android:layout_marginBottom="3dp"
android:layout_marginTop="-5dp"
/>
</RelativeLayout>
<RelativeLayout
android:id="@+id/rl_tournament"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_weight="