Add Image at above of listview

我与影子孤独终老i 提交于 2019-12-24 01:01:54

问题


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"?>


回答1:


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




回答2:


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>



回答3:


Try this code:​

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


来源:https://stackoverflow.com/questions/5376555/add-image-at-above-of-listview

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!