android listview的item 设置小技巧
我以前习惯插一个图片作为listview文字底纹
比如我有一个文件是listitem.xml 作为加载到listview的layout
以imageview加载一个底纹
<ImageView
android:id="@+id/listitem_bg"
android:layout_width="match_parent"
android:layout_height="180dp"
android:layout_alignParentLeft="true"
android:layout_alignParentTop="true"
android:src="@drawable/listitem_bg" />
使用相对布局,让文字出现在图片的上方,这是一种方法,一般情况下可以适应大部分手机。
但是我尝试放在平板里布局就会乱掉
其实这个时候改变一下思路会好很多
在布局中使用android:background=""
例如
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="180dp"
android:background="@drawable/listitem_bg">
这样子基本在所有分辨率里面,底纹都不会错位。
浙公网安备 33010602011771号