第七色在线视频,2021少妇久久久久久久久久,亚洲欧洲精品成人久久av18,亚洲国产精品特色大片观看完整版,孙宇晨将参加特朗普的晚宴

為了賬號(hào)安全,請(qǐng)及時(shí)綁定郵箱和手機(jī)立即綁定
已解決430363個(gè)問題,去搜搜看,總會(huì)有你想問的

將 xml 膨脹到 LinearLayout 后圖像按鈕 src 圖像消失了

將 xml 膨脹到 LinearLayout 后圖像按鈕 src 圖像消失了

吃雞游戲 2023-03-31 16:31:02
我有一個(gè)大致如下布局的 XML:<merge>    <LinearLayout (horizontal)>        <ImageButton/>        <ImageButton/>        <ImageButton/>    <LinearLayout/>    <TextView/><merge/> 當(dāng)我將 XML 擴(kuò)展到自定義垂直線性布局時(shí),一切都按預(yù)期進(jìn)行。每個(gè)項(xiàng)目的大小都是正確的,textView 顯示得很好。但是 ImageButtons 現(xiàn)在是完全透明的,并且沒有圖像,盡管我在模擬器中運(yùn)行我的應(yīng)用程序時(shí)指定了源。在 XML 編輯器的設(shè)計(jì)視圖中,我的 ImageButtons 有它們的源圖像并且看起來很好。以下是我在 XML 中大致看到的每個(gè) ImageButton 的樣子:<ImageButton android:id="@+id/endBtn"    android:layout_width="36dp"    android:layout_height="36dp"    android:layout_weight="1"    android:background="?android:selectableItemBackground"    android:elevation="12dp"    android:tint="@color/white"    app:srcCompat="@drawable/ic_close_black_24dp"    tools:srcCompat="@drawable/ic_close_black_24dp" />我在我的自定義視圖類中使用以下代碼膨脹視圖LinearLayout:LayoutInflater.from(context).inflate(R.layout.game_controls_view, this, true);我錯(cuò)過了什么?
查看完整描述

3 回答

?
揚(yáng)帆大魚

TA貢獻(xiàn)1799條經(jīng)驗(yàn) 獲得超9個(gè)贊

我認(rèn)為tint顏色與這里的可繪制對(duì)象混淆src。我建議刪除tint顏色并檢查圖像是否正在顯示。

如果這不起作用,請(qǐng)嘗試刪除app:srcCompattools:srcCompat僅用于ImageButton以下內(nèi)容。

<ImageButton
    android:id="@+id/endBtn"
    android:layout_width="36dp"
    android:layout_height="36dp"
    android:layout_weight="1"
    android:background="?android:selectableItemBackground"
    android:elevation="12dp"
    android:tint="@android:color/white"
    tools:srcCompat="@drawable/ic_launcher_background" />


查看完整回答
反對(duì) 回復(fù) 2023-03-31
?
白豬掌柜的

TA貢獻(xiàn)1893條經(jīng)驗(yàn) 獲得超10個(gè)贊

您正在使用 app:srcCompact. 來使用矢量可繪制對(duì)象,因此您需要將此行添加到您的 build.gradle 文件中。


defaultConfig {

    ...


    vectorDrawables.useSupportLibrary = true // This line here

}

第二種選擇是使用 android:src 來引用矢量可繪制對(duì)象。


查看完整回答
反對(duì) 回復(fù) 2023-03-31
?
湖上湖

TA貢獻(xiàn)2003條經(jīng)驗(yàn) 獲得超2個(gè)贊

Use this

<ImageButton android:id="@+id/endBtn"

? ? ? ? android:layout_width="36dp"

? ? ? ? android:layout_height="36dp"

? ? ? ? android:layout_weight="1"

? ? ? ? android:background="?android:selectableItemBackground"

? ? ? ? android:elevation="12dp"

? ? ? ? app:srcCompat="@drawable/ic_launcher_background"

? ? ? ? tools:srcCompat="@drawable/ic_launcher_background"

? ? ? ? tools:ignore="VectorDrawableCompat" />


查看完整回答
反對(duì) 回復(fù) 2023-03-31
  • 3 回答
  • 0 關(guān)注
  • 139 瀏覽
慕課專欄
更多

添加回答

舉報(bào)

0/150
提交
取消
微信客服

購(gòu)課補(bǔ)貼
聯(lián)系客服咨詢優(yōu)惠詳情

幫助反饋 APP下載

慕課網(wǎng)APP
您的移動(dòng)學(xué)習(xí)伙伴

公眾號(hào)

掃描二維碼
關(guān)注慕課網(wǎng)微信公眾號(hào)