开发者

How to change size of BitmapDrawable in accordance with size of TextView?

I have TextView with background picture in my layout and would like to开发者_JAVA百科 apply an animation to the text only. So, as I was advised in the separate question:

you could try embedding a TextView and a BitmapDrawable in a FrameLayout, then apply the animation to the TextView.

So, the question is what should be the layout that BitmapDrawable size would be changed in accordance with TextView size always?


Try setting the drawable on the FrameLayout itself. The FrameLayout will be the same size as the text, because of wrap_content, and so the background will be as well. The animation should only affect the drawing, not the actual layout, so this should still work when you animate it.

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

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜