Reputation: 17624
If I try to center the current view vertically within its parent. Which one should I use?
I saw TextViews use gravity="center_vertical" and ImageViews use
layout_centerVertical="true".
I am not sure why?
Upvotes: 0
Views: 453
Reputation: 5068
In textview
, gravity="center_vertical"
means the content in the textview
will be center
and vertical
. you can only see the alignment of text
if textview
is fill_parent
if its wrap_content
then there will be no place for content to have alignment.If you use layout_gravity
here and width and height to wrap_content
then it will place the textview
in the center _vertical of the parent layout.
In imageview
,layout_centerVertical="true".
means place iamge and in center
and vertical
in the parent layout of image (i.e the container of image).
Upvotes: 2