[英]Images won't show and/or won't work with buttons
我目前添加了一张图片,但它是灰色的。 按钮也不会按预期工作,但这可能是图像损坏的原因(因为代码似乎正确)。
U可以通过android:background="@android:drawable/..."
属性来更改按钮的android:background="@android:drawable/..."
。 但我认为您想获取switch
或ToogleButton
因此它应该是不同的View。
1>您可以为此使用Switch
。
2>如果要显示布局,请将ConstraintLayout
更改为LinearLayout
。
喜欢
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="horizontal" android:layout_width="match_parent"
android:layout_height="match_parent"
>
<ImageView
android:src="@mipmap/ic_launcher"
android:layout_width="wrap_content"
android:layout_height="wrap_content" />
<Button
android:layout_width="wrap_content"
android:layout_height="wrap_content" />
</LinearLayout>
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.