I want to align textview to vertically centre respect to EditView
my layout as follows
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical" >
<ScrollView
android:layout_width="fill_parent"
android:layout_height="wrap_content">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal"
android:gravity="center_vertical"
>
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="left"
android:layout_weight="1"
android:text="text1"/>
<EditText
android:id="@+id/setup_homeid"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="right"
android:layout_weight="1"
android:maxLength="5"
android:inputType="number"
android:hint=""/>
</LinearLayout>
</ScrollView>
how can i achieve it ?
thanks in advance
Change this android:layout_gravity="left"
into this,
android:layout_gravity="left|center_vertical"
or
android:layout_gravity="center_vertical"
for your TextView.
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="left|center_vertical"
android:layout_weight="1"
android:text="text1"/>
Add android:layout_gravity="center_vertical"
to your TextView tag. Change your TextView tag as below
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="left|center_vertical"
android:layout_weight="1"
android:text="text1"/>
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With