簡體   English   中英

將TextView放在ImageView前面

[英]Put a TextView in front of a ImageView

我正在尋找一種方法如何修復TextView,例如透明方塊,就像我在Paint.net中做的圖片一樣。因此TextView應該在透明方塊(ImageView)前面。當屏幕是大。

http://www7.pic-upload.de/22.02.14/24vtze5ulxc2.png

我該如何解決這個問題? 謝謝 !

使用FrameLayout

<FrameLayout
    android:layout_height="wrap_content"
    android:layout_width="wrap_content">

    <ImageView
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:src="@drawable/semi_transparent_background"/>

    <TextView
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:text="This is my text."/>

</FrameLayout>

或者,您可以使用相對布局執行類似的操作。

您可以使用RelativeLayout或FrameLayout。

<FrameLayout>
   <ImageView>
   <TextView>
</FrameLayout>

您的textview將出現在ImageView上。

雖然注意到,RelativeLayout有雙重征稅權衡。 每個度量和布局都會發生兩次。

簡單地在XML中從上到下排序RelativeLayout中的項目將使每個項目與其上方的其他項目相比向前移動。

暫無
暫無

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

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