Reputation: 911
I searched for an answer to my problem but i couldn't find one that goes with my situation.. So my application is an online shop for computers. I made two listViews and two custom rows.. one for the Shop and one for the basket. They both display some features of the product and it's picture in the right. My problem is my pictures (they are taken directly from the server) cannot fit correctly in my ImageViews and ListViews and i'm looking for a solution. Thank you in advance
Ps : i'm using Picasso library to display the picture. the used Picasso line of code :
Picasso.with(this.getContext()).load(lFoto).into(foto);
custom_row_shop.xml :
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="horizontal" >
<LinearLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:orientation="vertical" >
<LinearLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:orientation="horizontal" >
<TextView
android:id="@+id/list_ref"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_margin="5dp"
android:text="Ref Artikel :"
android:textColor="#2383c4"
android:textSize="11sp"
android:textStyle="bold" />
</LinearLayout>
<LinearLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:orientation="horizontal" >
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_margin="5dp"
android:text="Betriebssytem :"
android:textSize="9sp"
android:textStyle="bold" />
<TextView
android:id="@+id/list_betriebssystem"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_margin="5dp"
android:text="sldjq"
android:textSize="9sp" />
</LinearLayout>
<LinearLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:orientation="horizontal" >
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_margin="5dp"
android:text="Prozessor :"
android:textSize="9sp"
android:textStyle="bold" />
<TextView
android:id="@+id/list_prozessor"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_margin="5dp"
android:text="sldjq"
android:textSize="9sp" />
</LinearLayout>
<LinearLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:orientation="horizontal" >
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_margin="5dp"
android:text="Grafikkarte :"
android:textSize="9sp"
android:textStyle="bold" />
<TextView
android:id="@+id/list_grafikkarte"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_margin="5dp"
android:text="sldjq"
android:textSize="9sp" />
</LinearLayout>
<LinearLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:orientation="horizontal" >
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_margin="5dp"
android:text="RAM :"
android:textSize="9sp"
android:textStyle="bold" />
<TextView
android:id="@+id/list_arbeitsspeicher"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_margin="5dp"
android:text="sldjq"
android:textSize="9sp" />
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_margin="5dp"
android:text="Festplatte :"
android:textSize="9sp"
android:textStyle="bold" />
<TextView
android:id="@+id/list_festplatte"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_margin="5dp"
android:text="sldjq"
android:textSize="9sp" />
</LinearLayout>
</LinearLayout>
<ImageView
android:id="@+id/list_foto"
android:layout_width="90dp"
android:layout_height="90dp"
android:layout_marginLeft="40dp"
android:layout_marginTop="20dp"
android:scaleType="centerCrop"
android:src="@drawable/ic_launcher" />
</LinearLayout>
custom_row_basket.xml :
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="horizontal" >
<LinearLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:orientation="vertical" >
<LinearLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:orientation="horizontal" >
<TextView
android:id="@+id/list_warenKorb_ref"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_margin="5dp"
android:text="Ref Artikel :"
android:textColor="#2383c4"
android:textSize="11sp"
android:textStyle="bold" />
</LinearLayout>
<LinearLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:orientation="horizontal" >
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_margin="5dp"
android:text="Menge :"
android:textSize="9sp"
android:textStyle="bold" />
<TextView
android:id="@+id/list_warenKorb_menge"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_margin="5dp"
android:text="sldjq"
android:textSize="9sp" />
</LinearLayout>
<LinearLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:orientation="horizontal" >
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_margin="5dp"
android:text="Preis :"
android:textSize="9sp"
android:textStyle="bold" />
<TextView
android:id="@+id/list_warenKorb_preis"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_margin="5dp"
android:text="sldjq"
android:textSize="9sp" />
</LinearLayout>
</LinearLayout>
<ImageView
android:id="@+id/list_warenKorb_foto"
android:layout_width="70dp"
android:layout_height="70dp"
android:layout_marginLeft="120dp"
android:scaleType="centerCrop"
android:src="@drawable/ic_launcher" />
</LinearLayout>
Upvotes: 0
Views: 90
Reputation: 3348
Try this,
Use android:scaleType="fitXY"
<ImageView
android:id="@+id/list_foto"
android:layout_width="90dp"
android:layout_height="90dp"
android:layout_marginLeft="40dp"
android:layout_marginTop="20dp"
android:scaleType="fitXY"
android:src="@drawable/placeholder" />
Java class:
Picasso.with(this.getContext()).load(lFoto).into(foto);
Upvotes: 0
Reputation: 2954
You should use RelativeLayout
, try the layout below, the image fit the right, not cut off
custom_row_shop.xml :
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_toLeftOf="@+id/list_foto"
android:orientation="vertical">
<LinearLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:orientation="horizontal">
<TextView
android:id="@+id/list_ref"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_margin="5dp"
android:text="Ref Artikel :"
android:textColor="#2383c4"
android:textSize="11sp"
android:textStyle="bold" />
</LinearLayout>
<LinearLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:orientation="horizontal">
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_margin="5dp"
android:text="Betriebssytem :"
android:textSize="9sp"
android:textStyle="bold" />
<TextView
android:id="@+id/list_betriebssystem"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_margin="5dp"
android:text="sldjq"
android:textSize="9sp" />
</LinearLayout>
<LinearLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:orientation="horizontal">
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_margin="5dp"
android:text="Prozessor :"
android:textSize="9sp"
android:textStyle="bold" />
<TextView
android:id="@+id/list_prozessor"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_margin="5dp"
android:text="sldjq"
android:textSize="9sp" />
</LinearLayout>
<LinearLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:orientation="horizontal">
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_margin="5dp"
android:text="Grafikkarte :"
android:textSize="9sp"
android:textStyle="bold" />
<TextView
android:id="@+id/list_grafikkarte"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_margin="5dp"
android:text="sldjq"
android:textSize="9sp" />
</LinearLayout>
<LinearLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:orientation="horizontal">
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_margin="5dp"
android:text="RAM :"
android:textSize="9sp"
android:textStyle="bold" />
<TextView
android:id="@+id/list_arbeitsspeicher"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_margin="5dp"
android:text="sldjq"
android:textSize="9sp" />
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_margin="5dp"
android:text="Festplatte :"
android:textSize="9sp"
android:textStyle="bold" />
<TextView
android:id="@+id/list_festplatte"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_margin="5dp"
android:text="sldjq"
android:textSize="9sp" />
</LinearLayout>
</LinearLayout>
<ImageView
android:id="@+id/list_foto"
android:layout_width="90dp"
android:layout_height="90dp"
android:layout_marginLeft="40dp"
android:layout_marginTop="20dp"
android:scaleType="centerCrop"
android:layout_alignParentRight="true"
android:src="@drawable/ic_launcher" />
</RelativeLayout>
custom_row_basket.xml :
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="horizontal" >
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_toLeftOf="@+id/list_warenKorb_foto"
android:orientation="vertical" >
<LinearLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:orientation="horizontal" >
<TextView
android:id="@+id/list_warenKorb_ref"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_margin="5dp"
android:text="Ref Artikel :"
android:textColor="#2383c4"
android:textSize="11sp"
android:textStyle="bold" />
</LinearLayout>
<LinearLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:orientation="horizontal" >
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_margin="5dp"
android:text="Menge :"
android:textSize="9sp"
android:textStyle="bold" />
<TextView
android:id="@+id/list_warenKorb_menge"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_margin="5dp"
android:text="sldjq"
android:textSize="9sp" />
</LinearLayout>
<LinearLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:orientation="horizontal" >
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_margin="5dp"
android:text="Preis :"
android:textSize="9sp"
android:textStyle="bold" />
<TextView
android:id="@+id/list_warenKorb_preis"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_margin="5dp"
android:text="sldjq"
android:textSize="9sp" />
</LinearLayout>
</LinearLayout>
<ImageView
android:id="@+id/list_warenKorb_foto"
android:layout_width="70dp"
android:layout_height="70dp"
android:layout_marginLeft="120dp"
android:scaleType="centerCrop"
android:layout_alignParentRight="true"
android:src="@drawable/ic_launcher" />
</RelativeLayout>
Upvotes: 1
Reputation: 3272
Is the issue that your images are sometimes pushed to far to the right? That is what it looks like to me but not sure. If so try temporarily putting some background colors on the TextViews to see if they are taking up too much space.
Upvotes: 0