黑马程序员技术交流社区

标题: 怎么让GridView中的图片居中 [打印本页]

作者: 曹伟    时间: 2013-9-18 16:33
标题: 怎么让GridView中的图片居中
  1. <?xml version="1.0" encoding="utf-8"?>
  2. <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
  3.     android:layout_width="match_parent"
  4.     android:layout_height="match_parent"
  5.     android:orientation="horizontal">
  6.    
  7.    <GridView  
  8.         android:id="@+id/GridView1"  
  9.         android:layout_width="fill_parent"  
  10.         android:layout_height="wrap_content"
  11.         android:numColumns="4"></GridView>

  12. </LinearLayout>
复制代码
  1. <?xml version="1.0" encoding="utf-8"?>
  2. <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
  3.     android:layout_width="wrap_content"
  4.     android:layout_height="wrap_content">
  5.      <ImageView   
  6.                android:id="@+id/ItemImage"   
  7.                android:layout_width="wrap_content"
  8.                android:layout_height="wrap_content">   
  9.          </ImageView>
  10. </LinearLayout>
复制代码
现在运行出来,每行显示四张图片,如果屏幕太宽的话,图片之间就会有间隙,怎样调整才能没有间隙,图片在一行中居中呢?感谢!

作者: 比烟花寂寞_neve    时间: 2013-9-18 17:17
好久没有看Android,我当时是看这篇文章解决的,你可以看一下,http://fonter.iteye.com/blog/781403希望可以帮到你。
作者: 曹伟    时间: 2013-9-18 18:09
比烟花寂寞_neve 发表于 2013-9-18 17:17
好久没有看Android,我当时是看这篇文章解决的,你可以看一下,http://fonter.iteye.com/blog/781403希望可 ...

谢谢你!

作者: 比烟花寂寞_neve    时间: 2013-9-18 21:22
曹伟 发表于 2013-9-18 18:09
谢谢你!

我是黑马新手,以后多多支持





欢迎光临 黑马程序员技术交流社区 (http://bbs.itheima.com/) 黑马程序员IT技术论坛 X3.2