问题描述
我试图掩盖我的整个列表项与右侧阴影绘制。
问题是,我的布局包裹绘有没有一个恒定的高度。我累了我的设置可绘制对齐父顶部和调整父底部,但它仍然没有舒展其父布局的整个高度。
看ATT右边的阴影(我提供了一个最小height属性使其可见,第四列表项比最小观点大,影子不舒展)
来源:
< LinearLayout中的xmlns:机器人=http://schemas.android.com/apk/res/android
机器人:layout_width =FILL_PARENT
机器人:layout_height =WRAP_CONTENT
机器人:方向=垂直> <包括布局=@布局/ list_item_header/> < RelativeLayout的
机器人:layout_width =FILL_PARENT
机器人:layout_height =WRAP_CONTENT> < ImageView的
机器人:ID =@ + ID / img_news_thumb
机器人:layout_width =@扪/ listview_one_row
机器人:layout_height =@扪/ listview_one_row
机器人:scaleType =centerCrop
机器人:SRC =@绘制/ default_news_thumb/> <的TextView
机器人:ID =@ + ID / txt_news_title
机器人:layout_width =WRAP_CONTENT
机器人:layout_height =WRAP_CONTENT
机器人:layout_alignParentRight =真
机器人:layout_alignParentTop =真
机器人:layout_alignWithParentIfMissing =真
机器人:layout_marginLeft =@扪/ space_m
机器人:layout_marginTop =@扪/ space_s
机器人:layout_toRightOf =@ + ID / img_news_thumb
机器人:ellipsize =金字招牌
机器人:paddingRight =@扪/ space_m
机器人:单线=假
机器人:文字=标题
机器人:TEXTSIZE =14sp
机器人:文字样式=大胆/> <的TextView
机器人:ID =@ + ID / txt_news_date
机器人:layout_width =WRAP_CONTENT
机器人:layout_height =WRAP_CONTENT
机器人:layout_alignParentRight =真
机器人:layout_alignWithParentIfMissing =真
机器人:layout_below =@ + ID / txt_news_title
机器人:layout_marginBottom =0dp
机器人:layout_marginLeft =@扪/ space_m
机器人:layout_marginTop =@扪/ space_s
机器人:layout_toRightOf =@ + ID / img_news_thumb
机器人:ellipsize =结束
机器人:paddingRight =@扪/ space_m
机器人:单线=真
机器人:文字=日期
机器人:textAppearance =机器人:ATTR / textAppearanceSmall
机器人:文字颜色=@色/ font_light/> **< ImageView的
机器人:ID =@ + ID / img_news_list_shadow
机器人:layout_width =WRAP_CONTENT
机器人:layout_height =match_parent
机器人:layout_alignParentBottom =真
机器人:layout_alignParentRight =真
机器人:layout_alignTop =@ + ID / img_news_thumb
安卓了minHeight =@扪/ listview_one_row
机器人:scaleType =fitXY
机器人:SRC =@绘制/ list_shadow_r/> ** < ImageView的
机器人:ID =@ + ID / img_selected_arrow
机器人:layout_width =WRAP_CONTENT
机器人:layout_height =WRAP_CONTENT
机器人:layout_alignParentRight =真
机器人:layout_centerVertical =真
机器人:scaleType =fitXY
机器人:SRC =@绘制/ list_item_arrow
机器人:知名度=水涨船高/>
< / RelativeLayout的> <包括布局=@布局/ list_item_devider/>< / LinearLayout中>
由于最近的调查中,我发现,答案是比简单得多。
在充气的布局,我们应该用这样的:
查看rowView = inflater.inflate(R.layout.row_layout,父母,假);
而不是常用的错误:
查看rowView = inflater.inflate(R.layout.row_layout,NULL);
I'm trying to cover my entire list item with a shadow drawable on the right side.
Problem is that my layout wrapping the drawable has not a constant height. I tired to set my drawable to align parent top and align parent bottom but it still does not stretch the entire height of its parent layout.
look att the shadow on the right (I've provided a min height property to make it visible, the forth list item is bigger than min view, and the shadow does not stretch)
Source:
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:orientation="vertical" >
<include layout="@layout/list_item_header" />
<RelativeLayout
android:layout_width="fill_parent"
android:layout_height="wrap_content" >
<ImageView
android:id="@+id/img_news_thumb"
android:layout_width="@dimen/listview_one_row"
android:layout_height="@dimen/listview_one_row"
android:scaleType="centerCrop"
android:src="@drawable/default_news_thumb" />
<TextView
android:id="@+id/txt_news_title"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentRight="true"
android:layout_alignParentTop="true"
android:layout_alignWithParentIfMissing="true"
android:layout_marginLeft="@dimen/space_m"
android:layout_marginTop="@dimen/space_s"
android:layout_toRightOf="@+id/img_news_thumb"
android:ellipsize="marquee"
android:paddingRight="@dimen/space_m"
android:singleLine="false"
android:text="Title"
android:textSize="14sp"
android:textStyle="bold" />
<TextView
android:id="@+id/txt_news_date"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentRight="true"
android:layout_alignWithParentIfMissing="true"
android:layout_below="@+id/txt_news_title"
android:layout_marginBottom="0dp"
android:layout_marginLeft="@dimen/space_m"
android:layout_marginTop="@dimen/space_s"
android:layout_toRightOf="@+id/img_news_thumb"
android:ellipsize="end"
android:paddingRight="@dimen/space_m"
android:singleLine="true"
android:text="Date"
android:textAppearance="?android:attr/textAppearanceSmall"
android:textColor="@color/font_light" />
**<ImageView
android:id="@+id/img_news_list_shadow"
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:layout_alignParentBottom="true"
android:layout_alignParentRight="true"
android:layout_alignTop="@+id/img_news_thumb"
android:minHeight="@dimen/listview_one_row"
android:scaleType="fitXY"
android:src="@drawable/list_shadow_r" />**
<ImageView
android:id="@+id/img_selected_arrow"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentRight="true"
android:layout_centerVertical="true"
android:scaleType="fitXY"
android:src="@drawable/list_item_arrow"
android:visibility="gone" />
</RelativeLayout>
<include layout="@layout/list_item_devider" />
</LinearLayout>
Due to recent investigations, i've found out that the answer is much simpler than that.
When inflating the layout, we should use this:
View rowView = inflater.inflate(R.layout.row_layout, parent, false);
Instead of the commonly used error:
View rowView = inflater.inflate(R.layout.row_layout, null);
这篇关于里面有WRAP_CONTENT高度布局Match_parent高度的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!