這是個人佈局文件:android
<?xml version="1.0" encoding="utf-8"?>eclipse
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"佈局
android:layout_width="wrap_content"spa
android:layout_height="wrap_content"orm
android:layout_gravity="center"xml
android:gravity="center"圖片
android:orientation="vertical" >ip
<!-- 書封 -->utf-8
<ImageViewit
android:id="@+id/listview_grid_layout_iv_bookicon"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:contentDescription="@null" />
<!-- 書名 -->
<TextView
android:id="@+id/listview_grid_layout_tv_bookname"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center" />
</LinearLayout>
eclipse提示: This tag and its children can be replaced by one <TextView/> and a compound drawable
最後發現原來能夠直接給TextView加圖片.. ,經過 setCompoundDrawable 方法, 或者直接在xml中使用android:drawableLeft.、android:drawableRight等屬性指定。