Reputation: 665
I Have a Layout for my Activity,this layout consists a lot of widgets. in my activity data loaded from webservice in Listview. when listview is Adapted and fill All data. imagview was Invisible But I want show Imageview Below Listview when data Loaded.
My code in activity_main.xml:
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:id="@+id/rel_index"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="#f8f8f8"
tools:context=".MainActivity" >
<EditText
android:id="@+id/edt_search"
android:layout_width="fill_parent"
android:layout_height="40sp"
android:layout_marginLeft="10sp"
android:layout_marginRight="10sp"
android:layout_marginTop="115sp"
android:background="@drawable/round_corener_edittext"
android:drawableLeft="@drawable/center"
android:hint="@string/search"
android:paddingLeft="5sp"
android:paddingRight="5sp"
android:textColor="#44e1f4" />
<RelativeLayout
android:id="@+id/rel_top"
android:layout_width="fill_parent"
android:layout_height="135sp"
android:layout_marginBottom="25sp"
android:background="@drawable/header" >
<ImageView
android:id="@+id/img_logo"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerHorizontal="true"
android:layout_margin="10sp"
android:background="@drawable/digi_logo"
android:visibility="gone" />
<View
android:id="@+id/line"
android:layout_width="fill_parent"
android:layout_height="1dip"
android:layout_below="@+id/img_logo"
android:layout_centerHorizontal="true"
android:layout_marginLeft="20sp"
android:layout_marginRight="20sp"
android:background="#2391a2"
android:visibility="gone" />
<TextView
android:id="@+id/txt_app"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="@+id/line"
android:layout_centerHorizontal="true"
android:layout_marginBottom="10sp"
android:layout_marginTop="5sp"
android:text="@string/txt_name"
android:textColor="#1e7c95"
android:textSize="14sp"
android:visibility="gone" />
</RelativeLayout>
<ListView
android:id="@+id/lst_data"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_below="@+id/rel_top"
android:layout_marginBottom="10sp"
android:clipToPadding="false" />
<ImageView
android:id="@+id/img_offer"
android:layout_width="fill_parent"
android:layout_height="70sp"
android:layout_below="@+id/lst_data"
android:adjustViewBounds="true"
android:background="@drawable/offers_btn"
android:scaleType="fitXY" />
</RelativeLayout>
How to Resolve My Problms.thanks.
Upvotes: 2
Views: 1951
Reputation: 1477
private ImageView _imgView = null;
_imgView = new ImageView(this);
_listView.addFooterView(_imgView);
Try this; it may be able to help you.
Upvotes: 2
Reputation: 1566
What you are currently telling the layout inflater to do is place your header layout rel_top
at the top, then place a ListView
below it, and then place an ImageView
below that. What you want is basically to have the ImageView
anchored to the bottom of the display, and stretch the ListView
between the image and the header layout.
Instead of aligning your ImageView
below the ListView
you should align your ImageView
the the bottom of the screen
<ImageView
android:id="@+id/img_offer"
android:layout_width="fill_parent"
android:layout_height="70sp"
**android:layout_alignParentBottom="true"**
android:adjustViewBounds="true"
android:background="@drawable/offers_btn"
android:scaleType="fitXY" />
And align the ListView
to be below rel_top
and above the ImageView
<ListView
android:id="@+id/lst_data"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_below="@+id/rel_top"
**android:layout_above="@+id/img_offer"**
android:layout_marginBottom="10sp"
android:clipToPadding="false" />
Upvotes: 5