2

I would like to add imageview at above of listview. I knew about add section hearder in listview. But i just wanna save my time so i used image view for listview header instead of using addSectionHeader. Unfortunately i just stuck in with some xml properties. Image Overlay at my list view. Actually image supposed to be at the above of list. Check out my xml layout. Thanks.

<?xml version="1.0" encoding="utf-8"?>

Error

geekmyo
  • 179
  • 4
  • 19

3 Answers3

1

Use relative layout to have views about or below a listview.

You can tell views to align to top, bottom, left, or right and then have a margin to make room for the other view.

For example, if you want an image below your listview, you would align your listview to parent top and assign a bottom margin to the listview. Then align the imageview to parent bottom and the margin from the listview will make room for it.

Hope this makes sense.

EDIT:

Here is some code: I just wrote this of the top of my head so verify the tag properties but should give you the idea.

<?xml version="1.0" encoding="utf-8"?>  
<RelativeLayout
    xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_height="fill_parent"
    android:layout_width="fill_parent" >
    <ListView
        android:id="@+id/list"
        android:layout_height="wrap_content"
        android:layout_width="fill_parent"
        android:layout_marginBottom="50dp"
        android:layout_alignParentTop="true" />
    <TextView
        android:text="Some text"
        android:gravity="center"
        android:layout_height="wrap_content"
        android:layout_width="fill_parent"
        android:layout_alignParentBottom="true" />  
</RelativeLayout>
Anthony Graglia
  • 5,355
  • 5
  • 46
  • 75
1

this link states the same as of your problem EditText wont display above ListView

Community
  • 1
  • 1
Rohit Mandiwal
  • 10,258
  • 5
  • 70
  • 83
1

Try this code:​

TextView tv1=new TextView(context);
Resources res=getResources();
Drawable d1=res.getDrawable(R.drawable.YourImage);
tv1.setBackgroundDrawable(d1);
ListView.addHeaderView(tv1);
Fabian N.
  • 3,807
  • 2
  • 23
  • 46
Kartik Domadiya
  • 29,868
  • 19
  • 93
  • 104