簡體   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