0
我正试图在网格上方和下方显示图像。这是带有顶部徽标的初始屏幕,4个按钮用作网格视图,然后是底部的图像。用我目前的代码底部图像根本不显示。此外,我想将底部图像“bottomboxes”粘贴到显示屏的底部。如何在GridView上方和下方显示ImageView?
<ImageView
android:layout_height="wrap_content"
android:layout_width="wrap_content"
android:paddingTop="20dp"
android:src="@drawable/stuffbox"
android:gravity="center"/>
<GridView
android:id="@+id/gridview"
android:paddingTop="10dp"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:columnWidth="40dp"
android:numColumns="2"
android:verticalSpacing="10dp"
android:horizontalSpacing="10dp"
android:stretchMode="columnWidth"
android:gravity="center"/>
<ImageView
android:layout_height="wrap_content"
android:layout_width="wrap_content"
android:src="@drawable/bottomboxes"
android:paddingTop="20dp"
/>
</LinearLayout>
这工作得很好!我做出的唯一改变是改变 机器人:layout_height =“0” 到 机器人:layout_height =“WRAP_CONTENT” 不会再允许0 谢谢! – bdudaday 2010-07-07 22:15:53
@bdudaday对不起,应该是0dp。使用0dp仍然是最好的方法。您不应将layout_height设置为网格视图上的wrap_content,因为它会尝试测量它的内容。设置为零可以节省数量惊人的CPU。 – CodeFusionMobile 2010-07-08 22:34:16