如何在android中更改按钮图标?

时间:2014-03-28 09:38:37

标签: android icons

我想在我的应用程序中调整我即将开始的图标。

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

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

现在我还没有发布图片的声誉,告诉你我想要什么但是

简单我希望箭头用于后退和前进(自定义创建)而不是文本按钮

任何可以帮助我的人......?

3 个答案:

答案 0 :(得分:0)

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

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

答案 1 :(得分:0)

尝试以下代码

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

答案 2 :(得分:0)

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

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