GridView 的item高度很高,快崩溃了

ouye猿 2013-06-08 11:56:08
主布局中下面是一个gridView,点击后显示另外一个gridView,但是item的布局显示高度不合适,整体丑陋,求指点,谢谢!!

主布局

<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:orientation="vertical"
tools:context=".MainActivity" >
<LinearLayout
android:layout_width="fill_parent"
android:layout_height="30dp"
android:background="@drawable/cusor"
>
<ImageView
android:id="@+id/ivReturn"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:focusable="true"
android:layout_gravity="right"
android:paddingLeft="280dp"
android:visibility="gone"
android:src="@drawable/returnbtn"
android:onClick="doClick"
/>
</LinearLayout>
<ImageView
android:id="@+id/ivTitlePic"
android:layout_width="fill_parent"
android:layout_height="150dp"
android:src="@drawable/title3"
/>
<GridView
android:id="@+id/gvAlbum"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:horizontalSpacing="10dp"
android:verticalSpacing="10dp"
android:stretchMode="columnWidth"
android:layout_gravity="center"

android:numColumns="2"
android:visibility="visible"
/>
<GridView
android:id="@+id/gvPices"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:stretchMode="columnWidth"
android:horizontalSpacing="10dp"
android:verticalSpacing="10dp"
android:numColumns="3"
android:visibility="gone"
/>

</LinearLayout>


两个item的布局

第一:

<?xml version="1.0" encoding="utf-8"?>
<ImageView xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/ivAblum_item"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:scaleType="fitCenter"
android:src="@drawable/hnbc" >

</ImageView>



第二个

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:baselineAligned="false"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:orientation="vertical"
>
<ImageView
android:id="@+id/ivPic_item"
android:layout_width="fill_parent"
android:layout_height="0dp"
android:layout_weight="1.0"
android:src="@drawable/hnbc" >
</ImageView>
<TextView
android:text="dongfangb"
android:layout_width="fill_parent"
android:layout_height="0dp"
android:layout_weight="1.0"
android:textSize="12dp"
/>
</LinearLayout>


...全文
827 13 打赏 收藏 转发到动态 举报
写回复
用AI写文章
13 条回复
切换为时间正序
请发表友善的回复…
发表回复
jhere 2014-09-22
  • 打赏
  • 举报
回复
item的最外容器布局layout_height 改为固定高度dip,里面图的layout_weight=1
ouye猿 2013-06-15
  • 打赏
  • 举报
回复
ouye猿 2013-06-14
  • 打赏
  • 举报
回复
崩溃了 还是不行 除非设置固定值 我根据屏幕的尺寸来设定也不行!!!!哪位大牛给个解啊
凉凉二点凉 2013-06-09
  • 打赏
  • 举报
回复
有代码不,发来帮你看看
金笛子 2013-06-09
  • 打赏
  • 举报
回复
建议自己先画图 先整体分析好 然后给出多种解决方案。
passself 2013-06-09
  • 打赏
  • 举报
回复
Gridview里面的item会自动填充,如果想控制的话,可以有几种办法,一个是Gridview自身大小控制,其次是限制item的大小,想显示的作为item的子view出现,也需要限制大小
ouye猿 2013-06-09
  • 打赏
  • 举报
回复
引用 7 楼 guoyoulei520 的回复:
有代码不,发来帮你看看
上传不了附件?!!
ouye猿 2013-06-08
  • 打赏
  • 举报
回复
神啊 救救我吧
ouye猿 2013-06-08
  • 打赏
  • 举报
回复
引用 3 楼 guoyoulei520 的回复:
是不是gridview里面imageview的属性设置的有问题? 第一个布局中的imageview的高度设成wrap_content呢
你是说第一个gridview的item中的imageview的属性吗 设置wrap_content,还是不行,和原来一样
ouye猿 2013-06-08
  • 打赏
  • 举报
回复
感觉gridView的第一行占满了下面的这个空间
凉凉二点凉 2013-06-08
  • 打赏
  • 举报
回复
是不是gridview里面imageview的属性设置的有问题? 第一个布局中的imageview的高度设成wrap_content呢
ouye猿 2013-06-08
  • 打赏
  • 举报
回复
引用 1 楼 Android_app 的回复:
你把两个GridView的高度限制下,,固定高度看看
高度我设置了600dp 还是不行
kk1924 2013-06-08
  • 打赏
  • 举报
回复
你把两个GridView的高度限制下,,固定高度看看

80,351

社区成员

发帖
与我相关
我的任务
社区描述
移动平台 Android
androidandroid-studioandroidx 技术论坛(原bbs)
社区管理员
  • Android
  • yechaoa
  • 失落夏天
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧