【发布时间】:2014-12-19 12:50:51
【问题描述】:
我有一个布局,它的顶部应该有一个可滚动的列表视图,并且列表项应该是布局本身的大小!但是布局是用权重定义的......它应该是这样的:
但只要我添加带有列表项的适配器,视图就会调整大小!并将其他权重集(图像)视图推小! 而且我可以将列表项(这是一个单独的片段)设置为动态大小(如 100dp),但是在不同的分辨率下,它不会像它应该适合的布局那么大..
我的菜单布局:
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="vertical"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:weightSum="4">
<ListView
android:layout_width="fill_parent"
android:layout_height="0dp"
android:layout_weight="1"
android:id="@+id/startmenu_lv_spotlight"
android:listSelector="@drawable/selector_view" />
<LinearLayout
android:orientation="horizontal"
android:layout_width="fill_parent"
android:layout_weight="1"
android:layout_height="0dp"
android:weightSum="2">
<ImageView
android:src="@android:drawable/ic_menu_gallery"
android:layout_width="wrap_content"
android:id="@+id/startmenu_iv_shops"
android:layout_weight="1"
android:scaleType="centerCrop"
android:layout_height="fill_parent" />
<ImageView
android:src="@android:drawable/ic_menu_gallery"
android:layout_width="wrap_content"
android:layout_weight="1"
android:id="@+id/startmenu_iv_categories"
android:scaleType="centerCrop"
android:layout_height="fill_parent" />
</LinearLayout>
<ImageView
android:src="@android:drawable/ic_menu_gallery"
android:layout_width="fill_parent"
android:layout_weight="1"
android:id="@+id/startmenu_iv_review"
android:scaleType="centerCrop"
android:layout_height="0dp" />
<LinearLayout
android:orientation="horizontal"
android:layout_width="fill_parent"
android:layout_weight="1"
android:layout_height="0dp"
android:weightSum="2">
<ImageView
android:src="@android:drawable/ic_menu_gallery"
android:layout_weight="1"
android:layout_width="wrap_content"
android:scaleType="centerCrop"
android:id="@+id/startmenu_iv_newmovie"
android:layout_height="fill_parent" />
<ImageView
android:src="@android:drawable/ic_menu_gallery"
android:layout_weight="1"
android:layout_width="wrap_content"
android:scaleType="centerCrop"
android:id="@+id/startmenu_iv_personalactions"
android:layout_height="fill_parent" />
</LinearLayout>
</LinearLayout>
和我的列表项片段:
<?xml version="1.0" encoding="utf-8"?>
alright in the fragment of the listITEM i've changed to:
schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:orientation="horizontal"
android:layout_height="wrap_content"
android:weightSum="4">
<ImageView
android:id="@+id/deal_li_iv_icon_category"
android:src="@android:drawable/ic_menu_gallery"
android:layout_width="0dp"
android:layout_height="120dp"
android:layout_weight="1" />
<RelativeLayout
android:orientation="vertical"
android:layout_width="0dp"
android:layout_weight="3"
android:layout_height="fill_parent">
<TextView
android:id="@+id/deal_li_tv_text"
android:layout_toRightOf="@id/deal_li_iv_icon_category"
android:text="text here"
android:paddingTop="10dp"
android:layout_width="wrap_content"
android:layout_height="wrap_content" />
</LinearLayout>
我应该如何创建它,以便在我设置适配器时,ListView 不会调整其边界!并且列表项将与列表视图边界的高度一样大?
【问题讨论】:
-
将那些水平LinearLayouts中ImageViews的layout_width设置为0dp,而不是wrap_content
-
但问题是,我似乎无法弄清楚如何在列表视图中设置列表项的高度!到 listview.heigh 的大小...!
-
你有 wrap_content 作为高度。匹配/填充父级可能是您想要的更多
标签: android xml listview resize