Here is my code for xml file
<?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:background="#F8F8F8"> <RelativeLayout android:id="@+id/relative_buttons" android:layout_width="match_parent" android:layout_height="40dp" android:layout_centerHorizontal="true" android:layout_marginLeft="@dimen/dp_10" android:layout_marginRight="@dimen/dp_10" android:layout_marginTop="@dimen/dp_5" android:gravity="center" android:orientation="horizontal"> <com.hyper.barcodeapp.customClass.CustomButton android:id="@+id/btn_home" android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_weight="1" android:background="@drawable/home_sel" android:text="@string/home" android:textAllCaps="false" android:textColor="@android:color/white" android:textSize="@dimen/sp_16" /> <FrameLayout android:id="@+id/frame" android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_toRightOf="@+id/btn_home" android:layout_weight="1"> <com.hyper.barcodeapp.customClass.CustomButton android:id="@+id/btn_promotions" android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_weight="1" android:background="@drawable/promo" android:text="@string/promotions" android:textAllCaps="false" android:textColor="@android:color/tab_indicator_text" android:textSize="@dimen/sp_16" /> <TextView android:id="@+id/txt_badge" android:layout_width="15dp" android:layout_height="15dp" android:layout_alignRight="@id/btn_promotions" android:layout_alignTop="@id/btn_promotions" android:layout_gravity="top|right" android:layout_marginRight="@dimen/dp_1" android:layout_marginTop="@dimen/dp_1" android:background="@drawable/badge_circle" android:gravity="center" android:padding="@dimen/dp_3" android:text="10" android:textSize="5sp" /> </FrameLayout> <com.hyper.barcodeapp.customClass.CustomButton android:id="@+id/btn_search_code" android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_toRightOf="@+id/frame" android:layout_weight="1" android:background="@drawable/search" android:text="@string/search_code" android:textAllCaps="false" android:textColor="@android:color/tab_indicator_text" android:textSize="@dimen/sp_16" /> </RelativeLayout> <FrameLayout android:id="@+id/child_container" android:layout_width="match_parent" android:layout_height="match_parent" android:layout_below="@+id/relative_buttons" android:layout_marginTop="@dimen/dp_5" android:layout_weight="8"> </FrameLayout> </RelativeLayout>
Look at the code clearly, if “txt_badge” is a button, I see the “icon” icon on “btn_promotions”, but if I use Textview instead of a button, “txt_badge” does not appear in the layout, what could be the problem
Here is the badge_circle code
<shape xmlns:android="http://schemas.android.com/apk/res/android" android:shape="rectangle"> <corners android:radius="10dip" /> <solid android:color="@color/tab_button_text_color_not_clicked" /> <stroke android:width="1dip" android:color="#FFF" /> <padding android:bottom="5dip" android:left="5dip" android:right="5dip" android:top="5dip" /> </shape>
source share