开发者

Add Image at above of listview

I would like to add imageview at above of listview. I knew about add section hear开发者_运维知识库der 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"?>

Add Image at above of listview


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


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>


Try this code:​

TextView tv1=new TextView(context);
Resources res=getResources();
Drawable d1=res.getDrawable(R.drawable.YourImage);
tv1.setBackgroundDrawable(d1);
ListView.addHeaderView(tv1);
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜