Large margin by long title

Posted by Kevin Koenen on Stack Overflow See other posts from Stack Overflow or by Kevin Koenen
Published on 2012-06-29T21:12:12Z Indexed on 2012/06/29 21:15 UTC
Read the original article Hit count: 406

Filed under:
|

I try to show a list of offers. When an advertiser insert a large title, the margin of an item (offer) will be showed what shouldn't. I've tried different layouts but that doesn't work. Link to image :)

You see, some of the items has a large margin. Here's the code:

<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout 
xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/gallerylayout"
android:layout_width="fill_parent"
android:layout_height="fill_parent">
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
   android:layout_height="wrap_content" 
   android:gravity="left|center"
   android:layout_width="wrap_content" 
   android:paddingBottom="2dp"
   android:paddingTop="2dp" 
   android:paddingLeft="5dp"
   android:background="#20000000"
   android:cacheColorHint="#00000000">

    <ImageView
       android:id="@+id/ad_image_small"
       android:layout_width="wrap_content"
       android:layout_height="fill_parent"
       android:layout_marginRight="6dip"
       android:src="@drawable/ic_launcher"/>

    <LinearLayout
       android:orientation="vertical"
       android:layout_width="0dip"
       android:layout_weight="1"
       android:layout_height="fill_parent">

        <TextView 
            android:id="@+id/ad_id"
            android:visibility="gone"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"/>
        <TextView 
            android:id="@+id/ad_img_url"
            android:visibility="gone"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"/>

        <LinearLayout
           android:orientation="horizontal"
           android:layout_width="fill_parent"
           android:layout_height="wrap_content">
            <TextView android:id="@+id/ad_title"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:padding="3dp"
                android:gravity="left"
                android:textColor="#000000"
                android:ellipsize="end"
                android:singleLine="true"/>
            <TextView android:id="@+id/ad_km" 
                android:layout_width="match_parent" 
                android:layout_height="wrap_content"
                android:layout_margin="3dp" 
                android:layout_marginBottom="1dp"
                android:textColor="#000000"
                android:gravity="right"/>
        </LinearLayout>
        <LinearLayout
           android:orientation="horizontal"
           android:layout_width="fill_parent"
           android:layout_height="wrap_content">
            <TextView android:id="@+id/ad_text" 
                android:layout_width="wrap_content" 
                android:layout_height="wrap_content"
                android:layout_marginLeft="3dp" 
                android:textColor="#0099CC"
                android:ellipsize="end"
                android:singleLine="true"/>
        </LinearLayout>

        <LinearLayout
           android:orientation="horizontal"
           android:layout_width="fill_parent"
           android:layout_height="wrap_content"
           android:layout_margin="2dp"
           android:padding="5dp">
            <ImageView
                android:id="@+id/ad_clock"
                android:layout_width="20dp"
                android:layout_height="20dp"
                android:layout_marginRight="5dip"
                android:src="@drawable/icon_clock"/>
            <ProgressBar android:id="@+id/progressbar"
                android:layout_width="match_parent" 
                android:layout_height="8dp" 
                android:layout_margin="5dp"
                android:paddingLeft="2dp"
                android:max="100"
                style="?android:attr/progressBarStyleHorizontal"
                android:progressDrawable="@drawable/color_progressbar" />
        </LinearLayout>
    </LinearLayout>
</LinearLayout>

      <ImageView
        android:id="@+id/overlay_image"
        android:background="#0000"      
        android:src="@drawable/verlopen2x"
        android:layout_alignTop="@id/ad_image_small"
        android:layout_alignBottom="@id/ad_image_small"
        android:layout_width="fill_parent" 
        android:layout_height="wrap_content"
        android:adjustViewBounds="true"
        android:visibility="visible"
      />

I can't see what i'm doing wrong. Thanks in advance!

© Stack Overflow or respective owner

Related posts about java

Related posts about android