【问题标题】:How to change size of BitmapDrawable in accordance with size of TextView?如何根据 TextView 的大小改变 BitmapDrawable 的大小?
【发布时间】:2011-06-06 06:44:54
【问题描述】:

我的布局中有带有背景图片的TextView,并且只想对文本应用动画。所以,正如我在the separate question 中被告知的那样:

你可以尝试嵌入一个 TextView 和 FrameLayout 中的 BitmapDrawable, 然后将动画应用到 文本视图。

那么,问题是BitmapDrawable 的大小总是会根据TextView 的大小而改变的布局应该是什么?

【问题讨论】:

    标签: android bitmap textview


    【解决方案1】:

    尝试在 FrameLayout 本身上设置可绘制对象。 由于 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>
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2011-12-15
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多