In a relative layout, there are four bottom navigation bars of normal app, which are displayed in equal proportion by weight, but if Button and other custom controls (including non-custom controls) are placed in the relative layout of one proportion, then there will be the problem of Button covering other controls in the layout, but it also meets the problem. Not much, let's talk about what happened to me.
1.Button overrides other control examples:
<!--Good friend--> <RelativeLayout android:layout_width="0dp" android:layout_height="match_parent" android:layout_weight="1"> <Button android:id="@+id/main_btn2" style="@style/tab_button" android:layout_width="match_parent" android:layout_height="match_parent" android:drawableTop="@drawable/tab_chat_bg" android:onClick="onTabClicked" android:textAllCaps="false" android:textColor="@drawable/index_text" android:text="@string/friends" /> <TextView android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_alignParentRight="true" android:layout_marginRight="10dp" android:layout_marginTop="1dp" android:background="@drawable/unread_dot" android:gravity="center" android:text="7" android:textColor="@android:color/white" android:visibility="invisible" /> </RelativeLayout>
Of course, I did not use my own simulator to cover the problem, but a red rice Note4 appeared to cover the problem, resulting in Rongyun receiving unread messages can not show, very depressed, wasting half an hour to find the reason, and finally thought about whether the control coverage caused by the reason, the result is really...
2. The following is the revised layout, that is, to wrap Button up so that she does not have direct contact with other controls. This is also a small Bug of Android.
<!--news--> <RelativeLayout android:layout_width="0dp" android:layout_height="match_parent" android:layout_weight="1"> <LinearLayout android:layout_width="match_parent" android:orientation="vertical" android:layout_height="match_parent"> <Button android:id="@+id/main_btn_news" style="@style/tab_button" android:layout_width="match_parent" android:layout_height="match_parent" android:drawableTop="@drawable/tab_chat_bg" android:onClick="onTabClicked" android:textAllCaps="false" android:textColor="@drawable/index_text" android:text="@string/news" /> </LinearLayout> <!--<com.iruiyou.pet.utils.DragPointView--> <!--android:id="@+id/seal_num"--> <!--android:layout_width="19dp"--> <!--android:layout_height="19dp"--> <!--android:layout_alignParentRight="true"--> <!--android:layout_marginRight="18dp"--> <!--android:layout_marginTop="1dp"--> <!--android:textColor="@android:color/white"--> <!--android:textSize="12sp"--> <!--android:gravity="center"--> <!--android:visibility="invisible" />--> <RelativeLayout android:id="@+id/rl_main_im_red" android:gravity="center" android:layout_width="15dp" android:layout_height="15dp" android:layout_alignParentRight="true" android:layout_marginRight="18dp" android:layout_marginTop="1dp" android:layout_marginLeft="38dp" android:background="@drawable/bg_red_dot_corner"> <TextView android:id="@+id/tv_main_im_red" android:layout_width="wrap_content" android:layout_height="wrap_content" android:textColor="@color/black" android:textSize="8sp" /> </RelativeLayout>
This solves the problem.