android - How to have badge icon at corner of a layout -
i wanted have badge @ corner of layout . managed badge inside layout not able achieve @ corner of .
currently code gives me :
what want : want have badge on right top corner of layout .
i want :
toolbar.xml
<?xml version="1.0" encoding="utf-8"?> <android.support.v7.widget.toolbar xmlns:android="http://schemas.android.com/apk/res/android" xmlns:app="http://schemas.android.com/apk/res-auto" xmlns:tools="http://schemas.android.com/tools" android:layout_width="match_parent" android:layout_height="@dimen/toolbar_height" android:background="@color/toolbar_color" android:contentinsetleft="0dp" android:contentinsetstart="0dp" android:elevation="4dp" android:theme="@style/themeoverlay.appcompat.dark" app:contentinsetleft="0dp" app:contentinsetstart="0dp"> <linearlayout android:layout_width="match_parent" android:layout_height="match_parent" android:weightsum="1" android:orientation="horizontal"> <textview android:layout_width="wrap_content" android:layout_height="wrap_content" android:id="@+id/textview" android:text="my assignments" android:layout_gravity="center" android:gravity="center" android:layout_marginleft="90dp" android:layout_weight="0.5" android:textsize="20sp" /> <relativelayout android:id="@+id/bell_linearlayout1" android:layout_width="35dp" android:layout_height="35dp" android:layout_gravity="center" android:layout_marginleft="15dp"> <relativelayout android:id="@+id/bell_linearlayout" android:layout_width="50dp" android:layout_height="50dp" android:layout_gravity="center" android:background="#75aadb"> <imageview android:layout_width="match_parent" android:layout_height="wrap_content" android:layout_margintop="2dp" android:layout_centerinparent="true" android:id="@+id/carticonimageview" android:src="@drawable/notification"/> </relativelayout> <relativelayout android:layout_width="25dip" android:layout_height="25dip" android:gravity="end|top|right" android:layout_alignparenttop="true" android:layout_marginbottom="100dp" android:layout_marginleft="20dp"> <textview android:id="@+id/textview1" android:layout_width="15dp" android:layout_height="15dp" android:layout_alignparenttop="true" android:background="@drawable/badge" /> </relativelayout> </relativelayout> <linearlayout android:layout_width="35dp" android:layout_height="35dp" android:background="#75aadb" android:id="@+id/accountinfo_layout" android:layout_gravity="center" android:layout_marginleft="10dp"> <imageview android:layout_width="match_parent" android:layout_height="wrap_content" android:layout_margintop="1dp" android:src="@drawable/profile"/> </linearlayout> </linearlayout> </android.support.v7.widget.toolbar>
drawable badge.xml
<?xml version="1.0" encoding="utf-8"?> <shape xmlns:android="http://schemas.android.com/apk/res/android" android:shape="rectangle"> <corners android:radius="8dp" /> <solid android:color="#f20000" /> <stroke android:width="2dip" android:color="#fff" /> <padding android:bottom="6dp" android:left="6dp" android:right="6dp" android:top="6dp" /> </shape>
please .
<relativelayout xmlns:android="http://schemas.android.com/apk/res/android" xmlns:tools="http://schemas.android.com/tools" android:id="@+id/layoutforprofileimage" android:layout_width="100dp" android:layout_height="100dp"> <imageview android:id="@+id/image" android:layout_width="100dp" android:padding="2dp" android:src="@drawable/image" android:layout_height="100dp" android:layout_margin="6dp"/> <textview android:id="@+id/text" android:layout_width="wrap_content" android:layout_height="wrap_content" android:scaletype="fitstart" android:layout_marginright="0dp" android:padding="2dp" android:background="@drawable/button_pressed" android:gravity="center" android:minwidth="17sp" android:adjustviewbounds="true" android:minheight="17sp" android:paddingbottom="1dp" android:paddingleft="4dp" android:paddingright="4dp" android:text="0" android:textcolor="#ffffffff" android:textsize="12sp" android:visibility="visible" android:layout_gravity="center_horizontal" android:layout_alignparenttop="true" android:layout_alignparentend="true" /> </relativelayout>
Comments
Post a Comment