Reputation: 9189
I need to make a heading with an ImageView and TextView that are centered together, like the following diagram.
--------------------------------
| |
| ----------- ---------- |
| -ImageView- -TextView- |
| ----------- ---------- |
| |
| -Other Content- |
| |
The ImageView must be scaled to the height of the TextView and together they must be centered as if they were one widget. Any ideas on how to accomplish this?
Upvotes: 0
Views: 916
Reputation: 109237
EDIT: you can use TableLayout for it, put the textview and Imagview in 2 columns of tablerow, then your imageview is adjust acccording to your textview's columns height.
use your textview's height as wrap_content and imageview's height fill_parent
Upvotes: 2
Reputation: 24235
Use RelativeLayout
. Align ImageView
's top and bottom with TextView
's top and bottom. Set Top margins for textview. Set center horizontally to true in parent layout.
Upvotes: 0
Reputation: 81349
If they must look as a single widget, then wrap them with a horizontal LinearLayout, and actually do treat it like a single widget. Centering this new 'widget' will do what you want.
Upvotes: 1