Search code examples
androidandroid-layoutoverlap

How to remove unwanted overlapping in android


I am trying to make an Android interface, but I have a little overlapping issue with the views.

Here is my code. It is in a Tab, but I cut the Tab-part away. If you need it, I'll add it.

UPDATE: I forgot to write that I have a lot of TextView, not only one

<FrameLayout
        android:id="@android:id/tabcontent"
        android:layout_width="fill_parent"
        android:layout_height="fill_parent"
        android:padding="5dp" >

        <RelativeLayout
            android:layout_width="fill_parent"
            android:layout_height="fill_parent">

            <ScrollView
                android:orientation="vertical"
                android:layout_height="fill_parent"
                android:layout_width="fill_parent">

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

                <TextView
                    android:text="welcome"
                    android:layout_width="fill_parent"
                    android:layout_height="wrap_content"
                    android:layout_alignParentTop="true" />

                <!-- A lot of TextView as the one above -->

                </LinearLayout>
            </ScrollView>

            <RelativeLayout
                android:id="@+id/InnerRelativeLayout"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:layout_alignParentBottom="true" >

                <Button
                     android:id="@+id/add"
                     android:layout_height="wrap_content"
                     android:layout_alignParentRight="true"
                     android:layout_width="fill_parent"
                     android:text="@string/add" />
            </RelativeLayout>
        </RelativeLayout>
    </FrameLayout>

And this is what it outputs. As you can see, in the bottom, the text goes behind the button, but I want to have them in two different layouts

Screenshot


Solution

  • Try to position it relatively above the button.

    <RelativeLayout
            android:layout_width="fill_parent"
            android:layout_height="fill_parent">
    
            <ScrollView                
                android:orientation="vertical"
                android:layout_above="@+id/InnerRelativeLayout" //Add this
                android:layout_height="fill_parent"
                android:layout_width="fill_parent">
    
                <LinearLayout
                    android:orientation="vertical"
                    android:layout_height="fill_parent"
                    android:layout_width="fill_parent">
    
                <TextView
                    android:text="welcome"
                    android:layout_width="fill_parent"
                    android:layout_height="wrap_content"
                    android:layout_alignParentTop="true" />
    
                </LinearLayout>
            </ScrollView>
    
            <RelativeLayout
                android:id="@+id/InnerRelativeLayout"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:layout_alignParentBottom="true" >
    
                <Button
                     android:id="@+id/add"
                     android:layout_height="wrap_content"
                     android:layout_alignParentRight="true"
                     android:layout_width="fill_parent"
                     android:text="@string/add" />
            </RelativeLayout>
        </RelativeLayout>
    </FrameLayout>