Android : Align icon before "text" button in android

on Thursday, October 9, 2014


I would like to add a picture before the text "Accessar" within the button. As the picture below.


http://i.stack.imgur.com/0ASOE.png


I got the above effect in java class, I wonder if it is possible in xhtml.



<Button
android:id="@+id/login.button.cadastrese"
style="@style/ButtonsLogin"
android:background="@drawable/btn_login_cadastrese"
android:drawableLeft="@drawable/icon_login_cadastrese"
android:text="@string/login.btn.cadastre" />


work aligned to the button, not the text



Spannable buttonLabel = new SpannableString(getResources().getString(
R.string.login_btn_acessar));
buttonLabel.setSpan(new ImageSpan(getApplicationContext(),
R.drawable.icon_login_acessar, ImageSpan.ALIGN_BASELINE), 0, 1,
Spannable.SPAN_EXCLUSIVE_EXCLUSIVE);
btnLogin.setText(buttonLabel);


Resolves, but is much line to little effect. Thus, I have to add the string underlin _Acessar


0 comments:

Post a Comment