简体   繁体   中英

Android Relative Layout, Image on Full Height

Hello everybody I have following layout as ITEM LIST. The problem is that red view image (@+id/image) isn t filling it s parent. Can somebody help me ?

What i want to have is four lines with buttons and image that is stretched on right border
T - text
I - image
B - button
- - horizontal Divider

T         B  I
T T          I
____________ I
T         T  I



<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:id="@+id/dummy"
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    android:background="@color/tw_ticket_background"
    android:baselineAligned="true"
    android:clickable="true"
    android:descendantFocusability="blocksDescendants"
    android:longClickable="true">

<ImageView
    android:id="@+id/image"
    android:layout_width="wrap_content"
    android:layout_height="fill_parent"
    android:layout_alignParentRight="true"

    android:scaleType="fitXY"
    android:src="@drawable/red" />

<RelativeLayout
    android:id="@+id/firstLine"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:layout_alignParentLeft="true" >

    <TextView
        android:id="@+id/text1"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:text="text1"
        android:textSize="25sp" />

    <ImageButton
        android:id="@+id/infoIcon"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:background="@android:drawable/ic_menu_info_details" 
        android:layout_alignParentRight="true"
        android:layout_marginRight="10dp"/>
</RelativeLayout>

<RelativeLayout
    android:id="@+id/secondLine"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:layout_below="@+id/firstLine" >

    <TextView
        android:id="@+id/text2"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:text="text2"
        android:textSize="15sp" />

    <TextView
        android:id="@+id/text3"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_toRightOf="@+id/text2"
        android:text="text3"
        android:textSize="15sp" />
</RelativeLayout>

<View
    android:id="@+id/horizontalRule"
    android:layout_width="fill_parent"
    android:layout_height="2dp"
    android:layout_below="@+id/secondLine"
    android:background="#000000" 
    />

<RelativeLayout
    android:id="@+id/thirdLine"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:layout_below="@+id/horizontalRule" >

    <TextView
        android:id="@+id/text4"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:text="text4"
        android:textSize="15sp" />

    <TextView
        android:id="@+id/text5"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_alignParentRight="true"
        android:text="text5"
        android:textSize="15sp" 
        android:layout_marginRight="10dp"/>
</RelativeLayout>

</RelativeLayout>

Try this:

<ImageView
android:id="@+id/image"
android:layout_width="wrap_content"
android:layout_height="fill_parent"
android:layout_alignParentRight="true"
android:scaleType="fitXY"
android:background="@drawable/red" />

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM