繁体   English   中英

Android 按钮,左侧可绘制和两个文本行

[英]Android button with left drawable and two text lines

如何创建一个具有左侧可绘制图标和两行文本的按钮。 第一行小写,第二行大写并左对齐。 我创建了一个类似的按钮,但我无法将第二行左对齐。

按钮布局如下:

    <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>

我正在通过代码输入文本:

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

谢谢

尝试使用属性android:gravity="left" 默认情况下,Button 将其文本居中。

@drawable 不必是图像。 您可以在资源文件夹中创建 myicon.xml 并创建一个布局来保存按钮和 2 个文本视图。

线性布局设置为水平与您的图像和嵌套线性布局设置垂直包含文本视图。

粗略的想法在这里突出显示: http://blahti.wordpress.com/2011/03/14/build-dashboard-ui-for-android/

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM