如何根据TextView的大小更改BitmapDrawable的大小?

时间:2011-06-05 17:29:33

标签: android bitmap textview

我的布局中有TextView背景图片,并且只想将动画应用于文本。所以,正如我在the separate question中所建议的那样:

  

您可以尝试嵌入TextView和   FrameLayout中的BitmapDrawable,   然后将动画应用到   TextView的。

所以,问题是BitmapDrawable尺寸根据TextView尺寸总是会改变的布局应该是什么?

1 个答案:

答案 0 :(得分:1)

尝试在FrameLayout本身上设置drawable。 由于wrap_content,FrameLayout的大小与文本大小相同,因此背景也是如此。动画应仅影响绘图,而不影响实际布局,因此在为其设置动画时,这仍然有效。

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