I am displaying the TextView
within a RelativeLayout
.
I want to put the TextView
at the center of the Layout.
Within the layout xml, for TextView
am using the property android:gravity="center"
is not working .
I do not want to hard code by using android:layout_marginLeft
or Right since it can give different effect in portrait or landscape mode.
Is there property so that it looks the same for both landscape & portrait mode & the TextView
occupies the center of the Layout
Since RelativeLayout
is your TextView
's parent, you simply set android:layout_centerInParent="true"
on your TextView
. No other properties are needed.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.