android - Button with icon and text -


i make button in android :

connexion button

but don't know how that. have use relativelayout elements (imageview, textview, separator,...) ?

i don't know best practice.

you can use button property android: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 property android: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.

enter image description here

note : change drawable , color of choice.


Comments

Popular posts from this blog

javascript - Laravel datatable invalid JSON response -

java - Exception in thread "main" org.springframework.context.ApplicationContextException: Unable to start embedded container; -

sql server 2008 - My Sql Code Get An Error Of Msg 245, Level 16, State 1, Line 1 Conversion failed when converting the varchar value '8:45 AM' to data type int -