【问题标题】:android: how to add an image button?android:如何添加图片按钮?
【发布时间】:2010-04-06 00:10:18
【问题描述】:

我正在尝试用图像按钮替换我之前的丑陋文本按钮。但是,在使用以下 ImageButton 代码更改 XML 文件后,我的应用程序甚至无法启动。为什么?

<ImageButton 
android:layout_height="fill_parent"
     android:id="@+id/refresh"
android:src="@drawable/refresh"              
 /> 

【问题讨论】:

    标签: android image button


    【解决方案1】:

    指定布局宽度..

    android:layout_width="wrap_content/*some value ex:50dp*/" 
    

    【讨论】:

      【解决方案2】:

      原来我忘记了 layout_width 属性。现在可以了。

      <ImageButton 
              android:layout_height="fill_parent"
              android:id="@+id/refresh"
              android:src="@drawable/refresh"     
              android:layout_width="wrap_content"      
          /> 
      

      【讨论】:

        猜你喜欢
        • 2023-03-04
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 2011-05-11
        • 2020-08-07
        • 2013-05-25
        相关资源
        最近更新 更多