簡體   English   中英

如何根據 TextView 的大小改變 BitmapDrawable 的大小?

[英]How to change size of BitmapDrawable in accordance with size of TextView?

我的布局中有帶有背景圖片的TextView ,並且想僅將 animation 應用於文本。 因此,正如我在單獨的問題中所建議的那樣:

您可以嘗試在 FrameLayout 中嵌入 TextView 和 BitmapDrawable,然后將 animation 應用於 TextView。

那么,問題是, TextView BitmapDrawable大小而改變的布局應該是什么?

嘗試在 FrameLayout 本身上設置可繪制對象。 由於 wrap_content,FrameLayout 將與文本大小相同,因此背景也是如此。 animation 應該只影響繪圖,而不是實際布局,所以當你為它設置動畫時它應該仍然有效。

<FrameLayout
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:background="@drawable/your_background">
    <TextView
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:text="Hello World" />
</FrameLayout>

暫無
暫無

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

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