clcurie_11 2013-03-26 02:32 采纳率: 6.7%
浏览 3661
已采纳

在 Button 上添加 image 时,如何不使 image 紧靠在 Button 左边

给 Button 上添加 image 的时候如何在 image 的左边加空间,使得 image 左边不会紧靠在Button 的左边。
我使用的下面的代码,效果图是这样的:
CSDN移动问答

<LinearLayout
    android:layout_width="fill_parent"
    android:layout_height="wrap_content"
    android:layout_marginTop="45dp"   
    android:orientation="horizontal" >

           <Button   android:id="@+id/MyAccountbutton"
             style="?android:attr/buttonStyleSmall"
             android:layout_height="25dip"
                android:layout_width="fill_parent"
                android:layout_marginRight="35dip"
                android:layout_marginLeft="35dip"
            android:drawableLeft="@drawable/Handshake"
            android:background="@drawable/curvedplanebutton"
            android:textColor="@drawable/button_text_color"
            android:layout_marginTop="15dip"
            android:text="Payments"/>
           </LinearLayout>

我想实现的是这样的效果:
CSDN移动问答

就是让 Button 上的 image 不要紧靠在 Button 的左边,留点空间。如何实现呢?

  • 写回答

3条回答 默认 最新

  • chinabrant 2013-03-26 03:35
    关注

    可以加drawablePadding属性

    但这样drawable的四边都会出现相同的间距,代码中不知道可不可以只设置左边的padding

    最好的方法是:不要在button上加drawable,而是在你的linearLayout里面再加一个

    将图片单独放,这样就很好调整了,想怎么调就怎么调

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论
查看更多回答(2条)

报告相同问题?

悬赏问题

  • ¥20 双层网络上信息-疾病传播
  • ¥50 paddlepaddle pinn
  • ¥20 idea运行测试代码报错问题
  • ¥15 网络监控:网络故障告警通知
  • ¥15 django项目运行报编码错误
  • ¥15 请问这个是什么意思?
  • ¥15 STM32驱动继电器
  • ¥15 Windows server update services
  • ¥15 关于#c语言#的问题:我现在在做一个墨水屏设计,2.9英寸的小屏怎么换4.2英寸大屏
  • ¥15 模糊pid与pid仿真结果几乎一样