android - Button with icon and text -
i make button
in android :
but don't know how that. have use relativelayout
elements (imageview
, textview
, separator,...) ?
i don't know best practice.
you can use
button
propertyandroid:drawableleft="@drawable/ic_done"
.
refer this.
<button android:id="@+id/button111111" android:layout_width="wrap_content" android:layout_height="wrap_content" android:drawablepadding="5dp" android:layout_centerhorizontal="true" android:drawableleft="@drawable/ic_done" android:text="facebook" />
edit 1:
if want without using
button
propertyandroid:drawableleft="@drawable/ic_done"
then.
refer this.
create xml
file named shape.xml
inside res -> drawable
folder.
if don't see drawable folder in res directory create folder named drawable.
<?xml version="1.0" encoding="utf-8"?> <shape xmlns:android="http://schemas.android.com/apk/res/android"> <stroke android:width="3dip" android:color="@android:color/black" /> <corners android:radius="10dip" /> <padding android:bottom="10dip" android:left="10dip" android:right="10dip" android:top="10dip" /> </shape>
then refer layout.
<?xml version="1.0" encoding="utf-8"?> <linearlayout xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="match_parent" android:layout_height="wrap_content" android:background="@drawable/shape" android:gravity="center_vertical"> <imageview android:id="@+id/imageview" android:layout_width="wrap_content" android:layout_height="wrap_content" android:contentdescription="@string/app_name" android:src="@mipmap/ic_launcher" /> <view android:layout_width="2dp" android:layout_height="match_parent" android:layout_marginleft="10dp" android:background="@android:color/darker_gray" /> <button android:id="@+id/button" android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_marginleft="10dp" android:layout_weight="1" android:background="@null" android:text="submit" /> </linearlayout>
here screen.
note : change drawable
, color
of choice.
Comments
Post a Comment