【问题标题】:how change button Icons in android?如何更改android中的按钮图标?
【发布时间】:2014-05-07 16:29:40
【问题描述】:

我希望调整我即将开发的应用程序中的图标。

这是我正在关注的教程的链接。 "https://www.youtube.com/watch?v=lkadcYQ6SuY"

这是教程中给出和创建的示例。

现在我还没有发布图片向你展示我想要的东西的声誉,但是

简单我想要 箭头 用于前后(自定义创建)而不是文本按钮

谁能帮我...?

【问题讨论】:

  • 那么问题是什么,只需创建该按钮,然后将其用作应用程序中的图像视图或图像按钮。
  • 要显示图片吗?

标签: android icons


【解决方案1】:

试试下面的代码

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

【讨论】:

    【解决方案2】:

    您可以创建一个简单的按钮并为图片设置其背景。

        <Button
            android:id="@+id/button"
            android:background="@drawable/help"
            android:contentDescription="@string/help"
            android:gravity="bottom"
            android:onClick="showHelp" />
    

    或者你可以创建 ImageButton :

    <ImageButton
            android:id="@+id/sync"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_gravity="right|center_vertical"
            android:contentDescription="@string/sync"
            android:background="@android:color/transparent"            
            android:src="@drawable/sync" />
    

    【讨论】:

      【解决方案3】:

      您可以使用ImageButton,将您的图标放入drawable文件夹(如果它不存在,创建它),并将其设置为您的imageButton

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

      【讨论】:

        猜你喜欢
        • 2016-09-25
        • 1970-01-01
        • 2020-06-13
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 2018-01-15
        相关资源
        最近更新 更多