安卓 : How to make TextView with compound bitmap

标签 android bitmap textview

我想用复合位图创建一个 TextView,我知道 android 支持用复合可绘制对象创建 TextView,但我想在在线下载图像时复合位图

注意:我不想让 LinearLayout 保存 imageview 和 textview

最佳答案

以下是如何在 XML 代码中执行此操作。这会在顶部添加一个 Drawable 。您可以将其更改为左侧、右侧或底部:

<TextView
android:id="@+id/id"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:drawableTop="@drawable/yourdrawable"
/>

编辑

抱歉,完全误解了您的问题。您可以通过创建 BitmapDrawable 然后将其用作复合 Drawable 在代码中执行此操作。更多信息请点击:http://developer.android.com/reference/android/graphics/drawable/BitmapDrawable.html

关于安卓 : How to make TextView with compound bitmap,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/9651428/

相关文章:

android - 尝试膨胀自定义 View 时出现 stackoverflow 错误

c# - .ToBitmap : Missing 'Using Directive' or 'Assembly Reference'

java - 如何在 TextView 的文本周围设置边框

android - 从布局中获取位图

Android 无法通知项目评估监听器

android - 更新 ListFragment

WPF:如果位图经常更新,则呈现 WriteableBitmap 的最佳方法

安卓屏幕尺寸兼容性 : Bitmap?

android - 是否可以将可滚动的 TextView 添加到 ListView?

android - TextView.setText() 抛出 NullPointerException