繁体   English   中英

图片无法显示和/或无法通过按钮使用

[英]Images won't show and/or won't work with buttons

我目前添加了一张图片,但它是灰色的。 按钮也不会按预期工作,但这可能是图像损坏的原因(因为代码似乎正确)。

U可以通过android:background="@android:drawable/..."属性来更改按钮的android:background="@android:drawable/..." 但我认为您想获取switchToogleButton因此它应该是不同的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.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM