Question

This is part of my Layout:

<RelativeLayout
            android:layout_width="match_parent"
            android:layout_height="wrap_content" >

            <TextView
                android:id="@+id/name"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:layout_alignParentLeft="true"
                android:text="Large Text"
                android:textAppearance="@style/LargeText" />

            <Button
                android:id="@+id/editname"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:layout_alignBaseline="@+id/name"
                android:layout_alignParentRight="true"
                android:text="Edit"
                android:textAppearance="@style/LargeText" />
        </RelativeLayout>

In the result as you can see,

enter image description here

the Button gets partially hidden.

Please how do I solve this?

However, this is the full layout:

 <?xml version="1.0" encoding="utf-8"?>
 <ScrollView xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:ads="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent" >

<LinearLayout
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:orientation="vertical" >

    <!-- Dummy item to prevent AutoCompleteTextView from receiving focus -->

    <LinearLayout
        android:layout_width="0px"
        android:layout_height="0px"
        android:focusable="true"
        android:focusableInTouchMode="true" />

    <com.google.android.gms.ads.AdView
        android:id="@+id/adView"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        ads:adSize="SMART_BANNER"
        ads:adUnitId="xxxxxxxxxxxxxxxxx" />

    <LinearLayout
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:orientation="vertical"
        android:padding="@dimen/updatetrackerativty_padding" >

        <View
            android:layout_width="match_parent"
            android:layout_height="@dimen/updatetrackerativty_space"
            android:background="@android:color/transparent" />

        <RelativeLayout
            android:layout_width="match_parent"
            android:layout_height="wrap_content" >

            <TextView
                android:id="@+id/name"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:layout_alignParentLeft="true"
                android:text="Large Text"
                android:textAppearance="@style/LargeText" />

            <Button
                android:id="@+id/editname"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:layout_alignBaseline="@+id/name"
                android:layout_alignParentRight="true"
                android:text="Edit"
                android:textAppearance="@style/LargeText" />
        </RelativeLayout>

        <View
            android:layout_width="match_parent"
            android:layout_height="@dimen/updatetrackerativty_space"
            android:background="@android:color/transparent" />

        <View
            android:layout_width="match_parent"
            android:layout_height="1dp"
            android:background="@android:color/black" />

        <View
            android:layout_width="match_parent"
            android:layout_height="@dimen/updatetrackerativty_space"
            android:background="@android:color/transparent" />

        <RelativeLayout
            android:layout_width="match_parent"
            android:layout_height="wrap_content" >

            <LinearLayout
                android:id="@+id/phonelayout"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:orientation="vertical"
                android:layout_alignParentLeft="true" >

                <TextView
                    android:id="@+id/textView1"
                    android:layout_width="wrap_content"
                    android:layout_height="wrap_content"
                    android:text="Phone Number"
                    android:textAppearance="@style/LargeText" />

                <TextView
                    android:id="@+id/phone"
                    android:layout_width="wrap_content"
                    android:layout_height="wrap_content"
                    android:text="Medium Text"
                    android:textAppearance="@style/SmallText" />
            </LinearLayout>

            <LinearLayout
                android:id="@+id/buttonlayout"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:orientation="vertical"
                android:layout_alignParentRight="true" 
                android:layout_alignBaseline="@+id/phonelayout">

                <Button
                    android:id="@+id/editphone"
                    android:layout_width="wrap_content"
                    android:layout_height="wrap_content"
                    android:layout_alignParentRight="true"
                    android:text="Edit"
                    android:textAppearance="@style/LargeText" />
            </LinearLayout>
        </RelativeLayout>

        <View
            android:layout_width="match_parent"
            android:layout_height="@dimen/updatetrackerativty_space"
            android:background="@android:color/transparent" />

        <View
            android:layout_width="match_parent"
            android:layout_height="1dp"
            android:background="@android:color/black" />

        <View
            android:layout_width="match_parent"
            android:layout_height="@dimen/updatetrackerativty_space"
            android:background="@android:color/transparent" />

        <LinearLayout
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:orientation="vertical" >

            <TextView
                android:id="@+id/textView4"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:text="Continuous Tracking"
                android:textAppearance="@style/LargeText" />

            <RelativeLayout
                android:layout_width="match_parent"
                android:layout_height="wrap_content" >

                <CheckBox
                    android:id="@+id/continuousckbx"
                    android:layout_width="wrap_content"
                    android:layout_height="wrap_content"
                    android:layout_alignParentLeft="true"
                    android:text="Yes"
                    android:textAppearance="@style/SmallText" />

                <TextView
                    android:id="@+id/secondstextview"
                    android:layout_width="wrap_content"
                    android:layout_height="wrap_content"
                    android:layout_alignBaseline="@+id/continuousckbx"
                    android:layout_alignParentRight="true"
                    android:text="seconds"
                    android:textAppearance="@style/SmallText" />

                <LinearLayout
                    android:id="@+id/seconds"
                    android:layout_width="wrap_content"
                    android:layout_height="wrap_content"
                    android:layout_alignParentTop="true"
                    android:layout_toLeftOf="@+id/secondstextview"
                    android:orientation="vertical" >

                    <EditText
                        android:id="@+id/intervaledittext"
                        android:layout_width="wrap_content"
                        android:layout_height="wrap_content"
                        android:ems="3"
                        android:nextFocusLeft="@id/intervaledittext"
                        android:nextFocusUp="@id/intervaledittext"
                        android:numeric="integer" >
                    </EditText>

                    <TextView
                        android:id="@+id/thirtyand"
                        android:layout_width="wrap_content"
                        android:layout_height="wrap_content"
                        android:text="(30-255)"
                        android:textAppearance="@style/SmallText" />
                </LinearLayout>

                <TextView
                    android:id="@+id/intervaltextview"
                    android:layout_width="wrap_content"
                    android:layout_height="wrap_content"
                    android:layout_alignBaseline="@+id/continuousckbx"
                    android:layout_alignBottom="@+id/continuousckbx"
                    android:layout_toLeftOf="@+id/seconds"
                    android:text="Interval:"
                    android:textAppearance="@style/SmallText" />
            </RelativeLayout>
        </LinearLayout>

        <View
            android:layout_width="match_parent"
            android:layout_height="@dimen/updatetrackerativty_space"
            android:background="@android:color/transparent" />

        <View
            android:layout_width="match_parent"
            android:layout_height="1dp"
            android:background="@android:color/black" />

        <View
            android:layout_width="match_parent"
            android:layout_height="@dimen/updatetrackerativty_space"
            android:background="@android:color/transparent" />

        <LinearLayout
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:orientation="vertical" >

            <TextView
                android:id="@+id/TextView03"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:text="Record data"
                android:textAppearance="@style/LargeText" />

            <RelativeLayout
                android:layout_width="match_parent"
                android:layout_height="wrap_content" >

                <CheckBox
                    android:id="@+id/recorddata"
                    android:layout_width="wrap_content"
                    android:layout_height="wrap_content"
                    android:layout_alignParentLeft="true"
                    android:text="Yes"
                    android:textAppearance="@style/SmallText" />
            </RelativeLayout>
        </LinearLayout>

        <View
            android:layout_width="match_parent"
            android:layout_height="@dimen/updatetrackerativty_space"
            android:background="@android:color/transparent" />

        <View
            android:layout_width="match_parent"
            android:layout_height="1dp"
            android:background="@android:color/black" />

        <View
            android:layout_width="match_parent"
            android:layout_height="@dimen/updatetrackerativty_space"
            android:background="@android:color/transparent" />

        <LinearLayout
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:orientation="vertical" >

            <TextView
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:text="History"
                android:textAppearance="@style/LargeText" />

            <LinearLayout
                android:layout_width="match_parent"
                android:layout_height="wrap_content"
                android:gravity="right"
                android:orientation="horizontal" >

                <Button
                    android:id="@+id/plot"
                    android:layout_width="wrap_content"
                    android:layout_height="wrap_content"
                    android:layout_toLeftOf="@+id/clear"
                    android:text="Plot"
                    android:textAppearance="@style/LargeText" />

                <Button
                    android:id="@+id/clear"
                    android:layout_width="wrap_content"
                    android:layout_height="wrap_content"
                    android:layout_alignParentRight="true"
                    android:text="Clear"
                    android:textAppearance="@style/LargeText" />
            </LinearLayout>
        </LinearLayout>

        <View
            android:layout_width="match_parent"
            android:layout_height="@dimen/updatetrackerativty_space"
            android:background="@android:color/transparent" />

        <View
            android:layout_width="match_parent"
            android:layout_height="1dp"
            android:background="@android:color/black" />

        <View
            android:layout_width="match_parent"
            android:layout_height="@dimen/updatetrackerativty_space"
            android:background="@android:color/transparent" />

        <LinearLayout
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:orientation="vertical" >

            <TextView
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:text="Status"
                android:textAppearance="@style/LargeText" />

            <RelativeLayout
                android:layout_width="match_parent"
                android:layout_height="wrap_content" >

                <Button
                    android:id="@+id/activate"
                    android:layout_width="wrap_content"
                    android:layout_height="wrap_content"
                    android:layout_alignParentRight="true"
                    android:text="Activate"
                    android:textAppearance="@style/LargeText" />

                <TextView
                    android:id="@+id/status"
                    android:layout_width="wrap_content"
                    android:layout_height="wrap_content"
                    android:layout_alignBaseline="@+id/activate"
                    android:text="Inactive"
                    android:textAppearance="@style/SmallText"
                    android:textStyle="bold" />
            </RelativeLayout>
        </LinearLayout>
    </LinearLayout>
</LinearLayout>

</ScrollView>
Was it helpful?

Solution

Because you align your Edit Button with your name TextView Baseline , your TextView Baseline depends on it's content and height so in this case your first row has less height than your second so it's baseline is upper than second , because of this your Edit Button will align upper and it's height will cover by ceiling View. you can remove alignBaseline part and use android:layout_centerVertical="true"

OTHER TIPS

Try this.

<RelativeLayout
    android:layout_width="match_parent"
    android:layout_height="wrap_content" >

    <TextView
        android:id="@+id/name"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_alignParentLeft="true"
        android:text="Large Text"
        android:textAppearance="@style/LargeText" />

    <Button
        android:id="@+id/editname"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_alignParentRight="true"
        android:text="Edit"
        android:textAppearance="@style/LargeText" />
</RelativeLayout>

remove below line on xml:-

            android:layout_alignBaseline="@+id/name"
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top