簡體   English   中英

圖像未出現在 Android Studio 的相對布局中

[英]Image does not appear in Relative Layout of Android Studio

在Android Studio的Relative Layout中插入兩張圖片時,如下圖所示,可以看到已經在DrawableBottom、Foreground和Icon中插入了兩張圖片:

在此處輸入圖像描述

但是在移動設備上運行相同的圖形界面時,圖像不會出現。 請問,要怎么做才能讓圖片出現? 它在 Android Studio 的相對布局中。

在此處輸入圖像描述

按鈕或相對布局僅在設置android:background:"@drawable/seta_direita"時顯示圖像

按鈕:

<Button
       android:id="@+id/btn"
       android:layout_width="24dp"
       android:layout_height="24dp"
       android:background="@drawable/seta_direita"/>

相對布局:

 <RelativeLayout
           android:id="@+id/layout"
           android:layout_width="wrap_content"
           android:layout_height="wrap_content"
           android:background="@drawable/seta_direita">
 </RelativeLayout>  

當您只使用圖像作為背景時,您應該使用 ImageButton,而不是常規按鈕。

        <ImageButton
            android:id="@+id/btnSetaDireita"
            android:layout_width="0dp"
            android:layout_height="match_parent"
            android:layout_weight="1"
            android:src="@drawable/seta_direita"/>

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM