I have an imageView with an image, over that image I want to place a text. How can I achieve that?
相关问题
- How can I create this custom Bottom Navigation on
- Bottom Navigation View gets Shrink Down
- How to make that the snackbar action button be sho
- Listening to outgoing sms not working android
- How to create Circular view on android wear?
相关文章
- android开发 怎么把图片放入drawable的文件夹下
- android上如何获取/storage/emulated/下的文件列表
- androidStudio有个箭头不认识
- SQLite不能创建表
- Windows - Android SDK manager not listing any plat
- Animate Recycler View grid when number of columns
- Why is the app closing suddenly without showing an
- Android OverlayItem.setMarker(): Change the marker
Try the below code this will help you`
That is how I did it and it worked exactly as you asked for inside a RelativeLayout:
For this you can use only one TextView with
android:drawableLeft/Right/Top/Bottom
to position a Image to the TextView. Furthermore you can use some padding between the TextView and the drawable withandroid:drawablePadding=""
Use it like this:
With this you don't need an extra ImageView. It's also possible to use two drawables on more than one side of the TextView.
The only problem you will face by using this, is that the drawable can't be scaled the way of an ImageView.
You can use a TextView and change its background to the image you want to use
There are many ways. You use RelativeLayout or AbsoluteLayout.
With relative, you can have the image align with parent on the left side for example and also have the text align to the parent left too... then you can use margins and padding and gravity on the text view to get it lined where you want over the image.
You want to use a FrameLayout or a Merge layout to achieve this. Android dev guide has a great example of this here: Android Layout Tricks #3: Optimize by merging.