I am testing LinearLayout
and create a LinearLayout
with 2 TextView
s.
the LinearLayout
has the attribute gravity="center_vertical"
, and the first TextView
within the LinearLayout
has attribute layout_gravity="top"
.
gravity="center_vertical"
of LinearLayout
puts its content in center vertically.
layout_gravity="top"
of TextView
tells its container to put me on the top.
So what happened if they are together?
In my experiment, the 'layout_gravity="top"' does not work.
following is my code and result:
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="vertical" android:layout_width="match_parent"
android:layout_height="match_parent"
android:gravity="center_vertical">
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="top"
android:text="textview 1"/>
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="textview 2"/>
</LinearLayout>