4

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)

enter image description here

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> 
2

2 Answers 2

1

Found out it is not possible since the parent layout ie linear layout in this case always wraps content when used in a listview.

Sign up to request clarification or add additional context in comments.

Comments

0

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); 

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.