
这是xml文件:
<?xml version="1.0" enCoding="utf-8"?><relativeLayout xmlns:androID="http://schemas.androID.com/apk/res/androID"androID:orIEntation="horizontal"androID:layout_wIDth="fill_parent"androID:layout_height="fill_parent"androID:padding="8px" ><ImageVIEw androID:layout_wIDth="fill_parent" androID:layout_height="fill_parent" androID:src="@drawable/qbg1"/><TextVIEw androID:ID="@+ID/employeeID" androID:layout_wIDth="50px" androID:layout_marginRight="20px" androID:layout_height="wrap_content" androID:textcolor="@color/textcolor"/><TextVIEw androID:ID="@+ID/employeename" androID:layout_wIDth="wrap_content" androID:layout_marginRight="10px" androID:layout_height="wrap_content" androID:layout_toRightOf="@ID/employeeID" androID:textcolor="@color/textcolor"/></relativeLayout><ImageVIEw androID:layout_wIDth="fill_parent" androID:layout_height="fill_parent" androID:src="@drawable/qbg1"/>
将背景图像添加到活动的最佳方法是什么?我更喜欢在XML文件中而不是以编程方式.
解决方法 我通过将图像背景添加到主视图,然后在该视图中添加ListVIEw来解决了这个问题.所以这是我的main.xml文件:
<?xml version="1.0" enCoding="utf-8"?><relativeLayout xmlns:androID="http://schemas.androID.com/apk/res/androID"androID:orIEntation="vertical"androID:layout_wIDth="fill_parent"androID:layout_height="fill_parent"androID:paddingtop="4px"androID:background="@drawable/qbg"> <ListVIEw androID:ID="@androID:ID/List" androID:layout_wIDth="fill_parent" androID:layout_height="fill_parent" androID:drawSelectorOntop="false" androID:cachecolorHint="#00000000"/> //This is to fix disappearing background issue</relativeLayout>
这是我的ListVIEw.xml
<?xml version="1.0" enCoding="utf-8"?><relativeLayout xmlns:androID="http://schemas.androID.com/apk/res/androID"androID:orIEntation="horizontal"androID:layout_wIDth="fill_parent"androID:layout_height="fill_parent"androID:padding="8px" ><TextVIEwandroID:ID="@+ID/employeeID"androID:layout_wIDth="50px"androID:layout_marginRight="20px"androID:layout_height="wrap_content"androID:textcolor="@color/textcolor"/><TextVIEwandroID:ID="@+ID/employeename"androID:layout_wIDth="wrap_content"androID:layout_marginRight="10px"androID:layout_height="wrap_content"androID:layout_toRightOf="@ID/employeeID"androID:textcolor="@color/textcolor"/></relativeLayout>
希望这对其他人有益.
总结以上是内存溢出为你收集整理的在Android中将背景图片添加到listview?全部内容,希望文章能够帮你解决在Android中将背景图片添加到listview?所遇到的程序开发问题。
如果觉得内存溢出网站内容还不错,欢迎将内存溢出网站推荐给程序员好友。
欢迎分享,转载请注明来源:内存溢出
微信扫一扫
支付宝扫一扫
评论列表(0条)