Arbaz Alam Arbaz Alam - 21 days ago 5
Android Question

ListView is overlapped by Elements in Relative view

I have activity in which there is two EditText field, one button and one ListView. I want to show Two EditText Field and button in a rectangle box and below that list. I am not able to acheive this as listview is ovelapped by other as you can see in screenshot. Below is my activity.xml file.

<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
xmlns:ads="http://schemas.android.com/apk/res-auto"
android:orientation="vertical"
android:paddingBottom="0dp"
android:paddingLeft="0dp"
android:paddingRight="0dp"
android:paddingTop="0dp"
tools:context=".BalanceActivity_new"
android:background="#E6E6E6">




<RelativeLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical"
android:background="@drawable/testing"
android:elevation="5dp"
android:layout_marginTop="10dp">


<EditText
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:inputType="number"
android:ems="10"
android:id="@+id/uan"
android:layout_marginTop="10dp"
android:gravity="center"
android:hint="Enter 12 digit UAN Number"
android:textColorHint="@android:color/darker_gray"
android:maxLength="12"
android:textColor="@android:color/black" />

<EditText
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:inputType="phone"
android:ems="10"
android:textColorHint="@android:color/darker_gray"
android:id="@+id/mobile"
android:layout_marginTop="10dp"
android:gravity="center"
android:hint="Enter 10 digit Mobile Number"
android:layout_below="@id/uan"
android:maxLength="10"
android:textColor="@android:color/black" />


<Button
android:layout_width="212dp"
android:layout_height="40dp"
android:text="Show Balance"
android:id="@+id/show_1"
android:layout_marginTop="10dp"
android:gravity="center"
android:background="@android:color/white"
android:textSize="20sp"
android:textColor="@android:color/black"
android:textAlignment="center"
android:layout_marginBottom="5dp"
android:layout_below="@id/mobile"/>
</RelativeLayout>


<ListView
android:id="@+id/listView"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:divider="@android:color/transparent"
android:dividerHeight="10dp"
android:listSelector="@drawable/listview_selector"
android:scrollbars="none"
android:smoothScrollbar="true"
android:scrollingCache="false"
android:animationCache="false"
android:layout_marginBottom="52dp"
android:layout_alignParentLeft="true"
android:layout_alignParentStart="true">
</ListView>


<com.google.android.gms.ads.AdView
android:id="@+id/adView"
android:layout_width="match_parent"
android:layout_height="wrap_content"
ads:adSize="SMART_BANNER"
ads:adUnitId="@string/banner_home_footer"
android:layout_centerHorizontal="true"
android:layout_alignParentBottom="true"
android:layout_marginTop="1dp">
</com.google.android.gms.ads.AdView>

</RelativeLayout>


enter image description here

Answer

You need to add into RelativeLayout

android:id="@+id/relative_name"

and into your ListView

android:layout_below="@+id/relative_name"

to move the ListView below your Relative