Reputation: 20916
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:gravity="center_vertical"
android:minHeight="?android:attr/listPreferredItemHeight"
android:orientation="vertical"
android:paddingRight="?android:attr/scrollbarSize" >
<RelativeLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginBottom="6dip"
android:layout_marginLeft="15dip"
android:layout_marginRight="6dip"
android:layout_marginTop="6dip"
android:layout_weight="1" >
<TextView
android:id="@+android:id/title"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:ellipsize="marquee"
android:fadingEdge="horizontal"
android:singleLine="true"
android:text="222"
android:textAppearance="?android:attr/textAppearanceLarge" />
<TextView
android:id="@+android:id/summary"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignLeft="@android:id/title"
android:layout_below="@android:id/title"
android:maxLines="4"
android:text="222ssss"
android:textAppearance="?android:attr/textAppearanceSmall"
android:textColor="?android:attr/textColorSecondary" />
</RelativeLayout>
<RelativeLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginBottom="6dip"
android:layout_marginLeft="15dip"
android:layout_marginRight="6dip"
android:layout_marginTop="6dip"
android:layout_weight="1" >
<TextView
android:id="@+android:id/title"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:ellipsize="marquee"
android:fadingEdge="horizontal"
android:singleLine="true"
android:text="222"
android:textAppearance="?android:attr/textAppearanceLarge" />
<TextView
android:id="@+android:id/summary"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignLeft="@android:id/title"
android:layout_below="@android:id/title"
android:maxLines="4"
android:text="222ssss"
android:textAppearance="?android:attr/textAppearanceSmall"
android:textColor="?android:attr/textColorSecondary" />
</RelativeLayout>
<RelativeLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content">
<ImageView
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="@color/button_background_dark_default"
android:contentDescription="@string/image"
android:scaleType="fitXY" />
</RelativeLayout>
</<LinearLayout
but image is over the whole screen and no text is there. I want to see a text and under this text image which fill all empty space. How can i do that?
Upvotes: 0
Views: 86
Reputation: 1941
Is this what you are looking for? According to me your layout could be simplify with one simple linearLayout with android:orientation="vertical"
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:gravity="center_vertical"
android:minHeight="?android:attr/listPreferredItemHeight"
android:orientation="vertical"
android:paddingRight="?android:attr/scrollbarSize">
<TextView
android:id="@+id/text1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:ellipsize="marquee"
android:fadingEdge="horizontal"
android:singleLine="true"
android:text="222"
android:textAppearance="?android:attr/textAppearanceLarge"/>
<TextView
android:id="@+id/summary1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:maxLines="4"
android:text="222ssss"
android:textAppearance="?android:attr/textAppearanceSmall"
android:textColor="?android:attr/textColorSecondary"/>
<TextView
android:id="@+id/title2"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:ellipsize="marquee"
android:fadingEdge="horizontal"
android:singleLine="true"
android:text="222"
android:textAppearance="?android:attr/textAppearanceLarge"/>
<TextView
android:id="@+id/summary2"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:maxLines="4"
android:text="222ssss"
android:textAppearance="?android:attr/textAppearanceSmall"
android:textColor="?android:attr/textColorSecondary"/>
<ImageView
android:layout_width="match_parent"
android:layout_height="0dp"
android:layout_weight="1"
android:background="@color/button_background_dark_default"
android:scaleType="fitXY"/>
</LinearLayout>
The trick here are these attributs android:layout_height="0dp"
and android:layout_weight="1"
. It will tell to android that you want your image to fill all the empty space.
Upvotes: 2
Reputation: 23269
Change the holder of your ImageView
to a LinearLayout
<LinearLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content">
<ImageView
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="@color/button_background_dark_default"
android:contentDescription="@string/image"
android:scaleType="fitXY" />
</LinearLayout>
Your RelativeLayout
is expanding because of its match_parent
content.
Upvotes: 0
Reputation: 893
Try this---
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:gravity="center_vertical"
android:minHeight="?android:attr/listPreferredItemHeight"
android:orientation="vertical"
android:paddingRight="?android:attr/scrollbarSize" >
<RelativeLayout
android:id="@+id/rl_1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginBottom="6dip"
android:layout_marginLeft="15dip"
android:layout_marginRight="6dip"
android:layout_marginTop="6dip"
>
<TextView
android:id="@+android:id/title"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:ellipsize="marquee"
android:fadingEdge="horizontal"
android:singleLine="true"
android:text="222"
android:textAppearance="?android:attr/textAppearanceLarge" />
<TextView
android:id="@+android:id/summary"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignLeft="@android:id/title"
android:layout_below="@android:id/title"
android:maxLines="4"
android:text="222ssss"
android:textAppearance="?android:attr/textAppearanceSmall"
android:textColor="?android:attr/textColorSecondary" />
</RelativeLayout>
<RelativeLayout
android:id="@+id/rl_2"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginBottom="6dip"
android:layout_marginLeft="15dip"
android:layout_marginRight="6dip"
android:layout_marginTop="6dip"
android:layout_below="@id/rl_1" >
<TextView
android:id="@+android:id/title"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:ellipsize="marquee"
android:fadingEdge="horizontal"
android:singleLine="true"
android:text="222"
android:textAppearance="?android:attr/textAppearanceLarge" />
<TextView
android:id="@+android:id/summary"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignLeft="@android:id/title"
android:layout_below="@android:id/title"
android:maxLines="4"
android:text="222ssss"
android:textAppearance="?android:attr/textAppearanceSmall"
android:textColor="?android:attr/textColorSecondary" />
</RelativeLayout>
<RelativeLayout
android:id="@+id/img"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="@id/rl_2">
<ImageView
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="@color/button_background_dark_default"
android:contentDescription="@string/image"
android:scaleType="fitXY" />
</RelativeLayout>
</RelativeLayout>
Upvotes: 0
Reputation: 245
you should DEFINITLY not use nested linear/relative la yout like that.
anyway, try to put on the relativelayout around the image somthing like above or toleftof ect
EDIT : i didn't see your major layout was linear, then you'll have to use weight=1 on every inside layout,so that they don't priorityse on each other. but using relative layouts for one elements are just making your app slow
Upvotes: 0