gpt4 book ai didi

图像按钮上的Android图像未显示

转载 作者:塔克拉玛干 更新时间:2023-11-03 00:48:53 26 4
gpt4 key购买 nike

我面临的问题是,我无法将新图像按钮添加到我的 XML 文件中。我将我的图标添加到 Drawable,但它无法在图像按钮中显示。 XML 显示错误 ImageButton class not found。我该如何解决这个问题?

我在 xml 中得到以下错误

找不到以下类:- ImageButton(更改为 android.widget.ImageButton,修复构建路径,编辑 XML)

这是我的xml

   <?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical" >

<ImageButton
android:id="@+id/imageButton1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentTop="true"
android:layout_centerHorizontal="true"
android:layout_marginTop="109dp"
android:src="@drawable/facebook" />

</RelativeLayout>

最佳答案

你为什么不尝试一个简单的按钮而不是图像按钮。这是我在一些带有图像的按钮上的代码。android:drawableTop="@drawable/three" :这基本上就是图像android:background="@drawable/buttonstyles" :这是按钮的样式。无需使用它。或者我拥有的其他布局功能。

 <Button
android:id="@+id/button3"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignBottom="@+id/button2"
android:layout_alignParentRight="true"
android:layout_marginRight="20dp"
android:background="@drawable/buttonstyles"
android:drawableTop="@drawable/three"
android:onClick="goToSettings"
android:text="Settings" />

关于图像按钮上的Android图像未显示,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/21275188/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com