How to align Text in TextView for Android? -
i have png
file seems like:
i want create textview
should like:
here did far:
selector speaker.xml
<?xml version="1.0" encoding="utf-8"?> <selector xmlns:android="http://schemas.android.com/apk/res/android"> <item android:state_pressed="true" android:drawable="@drawable/speaker_over" /> <item android:state_enabled="false" android:drawable="@drawable/speaker_disabled" /> <item android:drawable="@drawable/speaker_default" /> </selector>
and textview
:
<textview android:id="@+id/speaker" android:background="@drawable/speaker" android:text="@string/button_speaker" android:gravity="center" android:textcolor="@drawable/text_incall_button_color" android:layout_width="match_parent" android:layout_height="wrap_content" android:layout_weight="0.94" />
string
<string name="button_speaker">speaker</string>
i don't know how align text "right-center" + "margin right"
in xcode ios it's simple, add margin left/right in pixel scale
how can in android?
use following
android:drawableleft="@drawable/image" android:text="@string/text"
use icon image..
by using android:drawableleft ,the drawable drawn left of text.
update:
use padding then
<textview android:id="@+id/micro" android:layout_width="match_parent" android:layout_height="wrap_content" android:layout_weight="0.94" android:background="@drawable/micro_on" android:paddingleft="80dp" android:paddingtop="15dp" android:text="@string/button_micro" android:textcolor="@drawable/text_incall_button_color" />
Comments
Post a Comment