开发者

Android button with left drawable and two text lines

How is possible to create a button that will have a left drawable icon and two lines of text. The first line is in lower case and the second line is in uppercase and aligned left. I have created a similar button BUT i I'm not able to align lef开发者_JAVA技巧t the second line.

The layout of button is:

    <Button android:layout_height="wrap_content" 
            android:id="@+id/mybutton" 
            android:layout_marginTop="25dp" 
            android:drawableLeft="@drawable/myicon" 
            android:text="Button" 
            android:textColor="@color/black" 
            android:layout_width="wrap_content" 
            android:textSize="12sp">
    </Button>

I'm putting the text through the code:

String txt = "some text<br><b>SOME TEXT</b>";
mybtn.setText(Html.fromHtml(txt));

Thank you


Try using the attribute android:gravity="left". By default a Button centers its text.


The @drawable doesn't have to be an image. You can create myicon.xml in your resource folder and create a layout to hold the button and 2 text views.

A linear layout set horizontal with your image and a nested linear layout set vertical that contains the text views.

The rough idea is highlighted here: http://blahti.wordpress.com/2011/03/14/build-dashboard-ui-for-android/

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜