如何在按钮中添加图像?用文字图片 [英] how do i add image in button? image with text

查看:198
本文介绍了如何在按钮中添加图像?用文字图片的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

您好,我想创建这样的方式 http://imgur.com/sshdf 在此URL图像按钮我如何像这样创建按钮?一半一半的图像文字?请帮助我,我想创建完全相同按钮

 <按钮机器人:ID =@ + ID / MyAccountMiniStatement
             风格=机器人:ATTR / buttonStyleSmall
             机器人:layout_height =25dip
                机器人:layout_width =FILL_PARENT
                机器人:layout_marginRight =10dip
                机器人:layout_marginLeft =10dip
            机器人:背景=@绘制/ curvedplanebutton
            机器人:文字颜色=@绘制/ button_text_color
            机器人:layout_marginTop =10dip
            机器人:文字=小陈述/>


解决方案

该属性添加到按钮的android:drawableLeft =@绘制/ ic_launcher

这样的事情,

 <按钮机器人:ID =@ + ID / MyAccountMiniStatement
        风格=机器人:ATTR / buttonStyleSmall
        机器人:layout_height =25dip
        机器人:layout_width =FILL_PARENT
        机器人:layout_marginRight =10dip
        机器人:layout_marginLeft =10dip
        机器人:drawableLeft =@绘制/ ic_launcher
        机器人:背景=@绘制/ curvedplanebutton
        机器人:文字颜色=@绘制/ button_text_color
        机器人:layout_marginTop =10dip
        机器人:文字=小陈述/>

通过提供可绘制左,图标将被放置到文本的左侧,你也可以使用背景属性来获得白色背景,你的整个按钮。

hi i want to create image button like this way http://imgur.com/sshdf in this url how do i create button like this? half image half text? please help me i wanna create exactly same button

           <Button   android:id="@+id/MyAccountMiniStatement"
             style="?android:attr/buttonStyleSmall"
             android:layout_height="25dip"
                android:layout_width="fill_parent"
                android:layout_marginRight="10dip"
                android:layout_marginLeft="10dip"


            android:background="@drawable/curvedplanebutton"
            android:textColor="@drawable/button_text_color"
            android:layout_marginTop="10dip"
            android:text="Mini Statement"/>

解决方案

Add this attribute to the button android:drawableLeft="@drawable/ic_launcher"

Something like this,

       <Button   android:id="@+id/MyAccountMiniStatement"
        style="?android:attr/buttonStyleSmall"
        android:layout_height="25dip"
        android:layout_width="fill_parent"
        android:layout_marginRight="10dip"
        android:layout_marginLeft="10dip"
        android:drawableLeft="@drawable/ic_launcher"
        android:background="@drawable/curvedplanebutton"
        android:textColor="@drawable/button_text_color"
        android:layout_marginTop="10dip"
        android:text="Mini Statement"/>

By providing the drawable Left, the icon will be placed to the left side of the text and also you can use the background attribute to give the white background to your whole button.

这篇关于如何在按钮中添加图像?用文字图片的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆