Android ImageView is rendering Bitmap images smaller while in ListView












0














I have a ListView, inside a linear layout, that should show items based on a list_item.xml layout file. In the layout file I have two ImageViews and two TextViews. I'm using my custom ArrayAdapter to fill the ListView at runtime with Bitmap images of scale 125x25, however images are showing smaller than their initial size when rendered by the ImageView inside the ListView as shown in the screenshot (of a single list item) below:



enter image description here



ActivityLayout.xml:



...
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_alignParentStart="true"
android:paddingTop="40dp"
android:orientation="vertical">

<ListView
android:id="@+id/lvExp"
android:layout_width="match_parent"
android:layout_height="match_parent" />

</LinearLayout>
...


List_item.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:minHeight="?android:attr/listPreferredItemHeight">

<ImageView
android:id="@+id/imageViewplate"
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:layout_alignParentLeft="true"
android:adjustViewBounds="true"
android:minWidth="300dp" />

<TextView
android:id="@+id/lblListItem_letter"
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:layout_marginLeft="10dp"
android:layout_toRightOf="@id/imageViewplate"
android:padding="3dp"
android:text="A"
android:textSize="17dip" />

<TextView
android:id="@+id/lblListItem_num"
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:layout_marginLeft="10dp"
android:layout_toRightOf="@id/lblListItem_letter"
android:padding="3dp"
android:text="123456"
android:textSize="17dip" />

<ImageView
android:id="@+id/imageViewchars"
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:layout_alignParentRight="true"
android:layout_alignParentBottom="true"
android:layout_marginLeft="10dp"
android:paddingTop="3dp"
android:paddingBottom="3dp" />

</RelativeLayout>


My custom list adapter:



    package bi.anpr.layouts;

import android.content.Context;
import android.support.design.widget.Snackbar;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ArrayAdapter;
import android.widget.ImageView;
import android.widget.TextView;

import com.sxx.vlctest.R;

import java.util.ArrayList;

import bi.anpr.agents.Plate;

public class PlateListAdapter extends ArrayAdapter<Plate>{

public PlateListAdapter(Context context, int resource) {
super(context, resource);
}

private ArrayList<Plate> dataSet;
Context mContext;

private static class ViewHolder {
public ImageView imageView_plate, imageView_chars;
public TextView textView_letter, textView_numbers;
}

private int lastPosition = -1;

@Override
public View getView(int position, View convertView, ViewGroup parent) {
// Get the data item for this position
Plate plate = getItem(position);
ViewHolder viewHolder;
final View result;

if (convertView == null) {
viewHolder = new ViewHolder();

LayoutInflater inflater = LayoutInflater.from(getContext());
convertView = inflater.inflate(R.layout.list_item, parent, false);

viewHolder.textView_letter = (TextView) convertView.findViewById(R.id.lblListItem_letter);
viewHolder.textView_numbers = (TextView) convertView.findViewById(R.id.lblListItem_num);
viewHolder.imageView_plate = (ImageView) convertView.findViewById(R.id.imageViewplate);
viewHolder.imageView_chars = (ImageView) convertView.findViewById(R.id.imageViewchars);
result = convertView;

convertView.setTag(viewHolder);
} else {
viewHolder = (ViewHolder) convertView.getTag();
result = convertView;
}

lastPosition = position;

try{
viewHolder.imageView_plate.setImageBitmap(plate.getEngPartImageIcon());
viewHolder.imageView_chars.setImageBitmap(plate.getcharsImageIcon());
viewHolder.textView_letter.setText(Character.toString(plate.getPlateLetter()));
viewHolder.textView_numbers.setText(plate.getPlateNumbersAsString());
}catch (Exception e){
e.printStackTrace();
}


// Return the completed view to render on screen
return convertView;
}
}


Plate.java:



package bi.anpr.agents;

import android.graphics.Bitmap;
import android.graphics.Canvas;
import android.graphics.Color;
import android.graphics.Paint;
import android.graphics.Typeface;

import java.io.Serializable;
import java.util.ArrayList;


import org.opencv.core.Mat;
import org.opencv.core.Rect;

import bi.anpr.core.IPHelper;

public class Plate implements Serializable {

private String platePath;
private boolean isWidePlate = true;
private int color;
private String colorString;
private String source = "";
private Rect bdgbx;
private Mat srcImage;
private Mat plateImage;
private Bitmap engPartImageIcon, plateImageIcon, forCutImageIcon, charsImageIcon, charsTextImageIcon;
private Mat engPartImage;
private Mat forCut;
private ArrayList<Character> plateNumberChars = new ArrayList<>();
private char plateLetterChar = '#';
private String fullPlateString = "";
private String numbersPlateString = "";
private double letterRate = 0;
private double numbersRate = 0;
private double accuracy = 0;
private int id;
private PlateRecogInfo plateRecogInfo;
private ArrayList<Bitmap> charsIcons = new ArrayList<>();
private boolean ignore = false;
private int accurayPercent = 0;

public Plate() {
plateRecogInfo = new PlateRecogInfo();
}

public void addPlateNumberChar(char c) {
plateNumberChars.add(c);
}

public Bitmap getplateImageIcon() {
return plateImageIcon;
}

public void setPlateImageIcon(Bitmap plateImageIcon) {
this.plateImageIcon = plateImageIcon;
}

public Bitmap getEngPartImageIcon() {
if (engPartImageIcon == null) {
engPartImageIcon = IPHelper.matToBitmap(engPartImage);
}
return engPartImageIcon;
}

public void setEngPartImageIcon(Bitmap engPartImageIcon) {
this.engPartImageIcon = engPartImageIcon;
}

public Mat getEngPartImage() {
return engPartImage;
}

public void setEngPartImage(Mat engPartImage) {
this.engPartImage = engPartImage;
}

public boolean isWidePlate() {
return isWidePlate;
}

public void setWidePlate(boolean isWidePlate) {
this.isWidePlate = isWidePlate;
}

public Mat getImage() {
return plateImage;
}

public void setImage(Mat Bitmap) {
plateImage = Bitmap;
}

public Bitmap getForCutImageIcon() {
if (forCutImageIcon == null) {
forCutImageIcon = IPHelper.matToBitmap(forCut);
}
return forCutImageIcon;
}

public Mat getForCut() {
return forCut;
}

public void setForCutImageIcon(Bitmap forCutImageIcon) {
this.forCutImageIcon = forCutImageIcon;
}

public void setForCut(Mat forCut) {
this.forCut = forCut;
}

public ArrayList<Character> getPlateNumberChar() {
return plateNumberChars;
}

public void setPlateNumberChar(ArrayList<Character> nchar) {
plateNumberChars = new ArrayList<Character>(nchar);
}

public char getPlateLetter() {
return plateLetterChar;
}

public void setPlateLetter(char plateLetter) {
plateLetterChar = plateLetter;
}

public int getId() {
return id;
}

public void setId(int id) {
this.id = id;
}

public double getLetterRate() {
return letterRate;
}

public void setLetterRate(double letterRate) {
this.letterRate = letterRate;
}

public double getCharsRate() {
return numbersRate;
}

public void setNumbersRate(double NumbersRate) {
this.numbersRate = NumbersRate;
}

public double getAccuracy() {
return accuracy;
}

public int getAccurayPercent() {
return accurayPercent;
}

public void setAccuracy(double totalRate) {
this.accuracy = totalRate;
this.accurayPercent = (int) (totalRate * 100);
}

public Mat getPlateImage() {
return plateImage;
}

public void setPlateImage(Mat matImage) {
this.plateImage = matImage;
plateImageIcon = IPHelper.matToBitmap(matImage);
}

public PlateRecogInfo getPlateRecogInfo() {
return plateRecogInfo;
}

public void setPlateRecogInfo(PlateRecogInfo plateRecogInfo) {
this.plateRecogInfo = plateRecogInfo;
}

public void addCharIcon(Mat charsIcons) {
this.charsIcons.add(IPHelper.matToBitmap(charsIcons));
}

public Bitmap getcharsImageIcon() {
if (charsImageIcon == null) {
int width = 5;
int height = 0;
for (Bitmap icon : charsIcons) {
if (icon.getHeight() > height)
height = icon.getHeight();
width += icon.getWidth() + 5;
}
height += 6;

charsImageIcon = Bitmap.createBitmap(width, height, Bitmap.Config.ARGB_8888);
Canvas canvas = new Canvas(charsImageIcon);

int i = 0;
for (Bitmap icon : charsIcons) {
canvas.drawBitmap(icon, i, 3, null);
i += icon.getWidth() + 5;
}
}

return charsImageIcon;
}

public Bitmap getCharsTextImageIcon() {
if (charsTextImageIcon == null) {
String chars = "";
for (Character c : plateNumberChars) {
String cs = c.toString();
chars += cs;
}

int width = 5;
int height = 0;
for (Bitmap icon : charsIcons) {
if (icon.getHeight() > height)
height = icon.getHeight();
width += icon.getWidth() + 5;
}
height += 6;

charsTextImageIcon = Bitmap.createBitmap(width, height, Bitmap.Config.ARGB_8888);
Canvas canvas = new Canvas(charsTextImageIcon);

int i = 0;
int j = 0;

Paint paint = new Paint(Paint.ANTI_ALIAS_FLAG);
paint.setTypeface(Typeface.create(Typeface.DEFAULT, Typeface.BOLD));
paint.setColor(Color.BLACK);
paint.setTextSize(16);

canvas.drawColor(Color.WHITE);

for (Bitmap icon : charsIcons) {

if (j == 0)
canvas.drawText("Some Text", i + 2, 19, paint);
else
canvas.drawText(Character.toString(chars.charAt(j - 1)), i + 3, 19, paint);

i += icon.getWidth() + 5;
j++;
}

}

return charsTextImageIcon;
}

public void setCharsTextImageIcon(Bitmap charsTextImageIcon) {
this.charsTextImageIcon = charsTextImageIcon;
}

public Mat getSrcImage() {
return srcImage;
}

public void setSrcImage(Mat srcImage) {
this.srcImage = srcImage;
}

public Rect getBdgbx() {
return bdgbx;
}

public void setBdgbx(Rect bdgbx) {
this.bdgbx = bdgbx;
}

public int getColor() {
return color;
}

// public Color getColorObject() {
// int color = getColor();
//
// try {
// return Color.parseColor(Color.rgb(color[0], color[1], color[2]));
// } catch (Exception e) {
// }
// return null;
// }

public void setColor(int is) {
this.color = is;
}

public String getColorString() {
return colorString;
}

public void setColorString(String colorString) {
this.colorString = colorString;
}

public String getFullPlateCharsString() {
if (fullPlateString == "" || fullPlateString == null) {
fullPlateString += plateLetterChar;
for (Character c : plateNumberChars) {
fullPlateString += c.toString();
}
}

return fullPlateString;
}

public void setFullPlateString(String fullPlateString) {
this.fullPlateString = fullPlateString;
}

public void setNumbersPlateString(String numbersPslateString) {
this.numbersPlateString = numbersPslateString;
}

public String getPlateNumbersAsString() {
if (numbersPlateString == "" || numbersPlateString == null) {
for (Character c : plateNumberChars) {
numbersPlateString += c.toString();
}
}

return numbersPlateString;
}

public String getPlatePath() {
return platePath;
}

public void setPlatePath(String platePath) {
this.platePath = platePath;
}

public boolean isIgnore() {
return ignore;
}

public void setIgnore(boolean ignore) {
this.ignore = ignore;
}

public String getSource() {
return source;
}

public void setSource(String source) {
this.source = source;
}

}


Usage:



PlateListAdapter plateListAdapter = new PlateListAdapter(getApplicationContext(), R.layout.list_item);
ListView resultsListView = (ListView) findViewById(R.id.lvExp);
resultsListView.setAdapter(plateListAdapter);
plateListAdapter.addAll(recogInfo.getPlates());
plateListAdapter.notifyDataSetChanged();









share|improve this question





























    0














    I have a ListView, inside a linear layout, that should show items based on a list_item.xml layout file. In the layout file I have two ImageViews and two TextViews. I'm using my custom ArrayAdapter to fill the ListView at runtime with Bitmap images of scale 125x25, however images are showing smaller than their initial size when rendered by the ImageView inside the ListView as shown in the screenshot (of a single list item) below:



    enter image description here



    ActivityLayout.xml:



    ...
    <LinearLayout
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:layout_alignParentStart="true"
    android:paddingTop="40dp"
    android:orientation="vertical">

    <ListView
    android:id="@+id/lvExp"
    android:layout_width="match_parent"
    android:layout_height="match_parent" />

    </LinearLayout>
    ...


    List_item.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:minHeight="?android:attr/listPreferredItemHeight">

    <ImageView
    android:id="@+id/imageViewplate"
    android:layout_width="wrap_content"
    android:layout_height="match_parent"
    android:layout_alignParentLeft="true"
    android:adjustViewBounds="true"
    android:minWidth="300dp" />

    <TextView
    android:id="@+id/lblListItem_letter"
    android:layout_width="wrap_content"
    android:layout_height="match_parent"
    android:layout_marginLeft="10dp"
    android:layout_toRightOf="@id/imageViewplate"
    android:padding="3dp"
    android:text="A"
    android:textSize="17dip" />

    <TextView
    android:id="@+id/lblListItem_num"
    android:layout_width="wrap_content"
    android:layout_height="match_parent"
    android:layout_marginLeft="10dp"
    android:layout_toRightOf="@id/lblListItem_letter"
    android:padding="3dp"
    android:text="123456"
    android:textSize="17dip" />

    <ImageView
    android:id="@+id/imageViewchars"
    android:layout_width="wrap_content"
    android:layout_height="match_parent"
    android:layout_alignParentRight="true"
    android:layout_alignParentBottom="true"
    android:layout_marginLeft="10dp"
    android:paddingTop="3dp"
    android:paddingBottom="3dp" />

    </RelativeLayout>


    My custom list adapter:



        package bi.anpr.layouts;

    import android.content.Context;
    import android.support.design.widget.Snackbar;
    import android.view.LayoutInflater;
    import android.view.View;
    import android.view.ViewGroup;
    import android.widget.ArrayAdapter;
    import android.widget.ImageView;
    import android.widget.TextView;

    import com.sxx.vlctest.R;

    import java.util.ArrayList;

    import bi.anpr.agents.Plate;

    public class PlateListAdapter extends ArrayAdapter<Plate>{

    public PlateListAdapter(Context context, int resource) {
    super(context, resource);
    }

    private ArrayList<Plate> dataSet;
    Context mContext;

    private static class ViewHolder {
    public ImageView imageView_plate, imageView_chars;
    public TextView textView_letter, textView_numbers;
    }

    private int lastPosition = -1;

    @Override
    public View getView(int position, View convertView, ViewGroup parent) {
    // Get the data item for this position
    Plate plate = getItem(position);
    ViewHolder viewHolder;
    final View result;

    if (convertView == null) {
    viewHolder = new ViewHolder();

    LayoutInflater inflater = LayoutInflater.from(getContext());
    convertView = inflater.inflate(R.layout.list_item, parent, false);

    viewHolder.textView_letter = (TextView) convertView.findViewById(R.id.lblListItem_letter);
    viewHolder.textView_numbers = (TextView) convertView.findViewById(R.id.lblListItem_num);
    viewHolder.imageView_plate = (ImageView) convertView.findViewById(R.id.imageViewplate);
    viewHolder.imageView_chars = (ImageView) convertView.findViewById(R.id.imageViewchars);
    result = convertView;

    convertView.setTag(viewHolder);
    } else {
    viewHolder = (ViewHolder) convertView.getTag();
    result = convertView;
    }

    lastPosition = position;

    try{
    viewHolder.imageView_plate.setImageBitmap(plate.getEngPartImageIcon());
    viewHolder.imageView_chars.setImageBitmap(plate.getcharsImageIcon());
    viewHolder.textView_letter.setText(Character.toString(plate.getPlateLetter()));
    viewHolder.textView_numbers.setText(plate.getPlateNumbersAsString());
    }catch (Exception e){
    e.printStackTrace();
    }


    // Return the completed view to render on screen
    return convertView;
    }
    }


    Plate.java:



    package bi.anpr.agents;

    import android.graphics.Bitmap;
    import android.graphics.Canvas;
    import android.graphics.Color;
    import android.graphics.Paint;
    import android.graphics.Typeface;

    import java.io.Serializable;
    import java.util.ArrayList;


    import org.opencv.core.Mat;
    import org.opencv.core.Rect;

    import bi.anpr.core.IPHelper;

    public class Plate implements Serializable {

    private String platePath;
    private boolean isWidePlate = true;
    private int color;
    private String colorString;
    private String source = "";
    private Rect bdgbx;
    private Mat srcImage;
    private Mat plateImage;
    private Bitmap engPartImageIcon, plateImageIcon, forCutImageIcon, charsImageIcon, charsTextImageIcon;
    private Mat engPartImage;
    private Mat forCut;
    private ArrayList<Character> plateNumberChars = new ArrayList<>();
    private char plateLetterChar = '#';
    private String fullPlateString = "";
    private String numbersPlateString = "";
    private double letterRate = 0;
    private double numbersRate = 0;
    private double accuracy = 0;
    private int id;
    private PlateRecogInfo plateRecogInfo;
    private ArrayList<Bitmap> charsIcons = new ArrayList<>();
    private boolean ignore = false;
    private int accurayPercent = 0;

    public Plate() {
    plateRecogInfo = new PlateRecogInfo();
    }

    public void addPlateNumberChar(char c) {
    plateNumberChars.add(c);
    }

    public Bitmap getplateImageIcon() {
    return plateImageIcon;
    }

    public void setPlateImageIcon(Bitmap plateImageIcon) {
    this.plateImageIcon = plateImageIcon;
    }

    public Bitmap getEngPartImageIcon() {
    if (engPartImageIcon == null) {
    engPartImageIcon = IPHelper.matToBitmap(engPartImage);
    }
    return engPartImageIcon;
    }

    public void setEngPartImageIcon(Bitmap engPartImageIcon) {
    this.engPartImageIcon = engPartImageIcon;
    }

    public Mat getEngPartImage() {
    return engPartImage;
    }

    public void setEngPartImage(Mat engPartImage) {
    this.engPartImage = engPartImage;
    }

    public boolean isWidePlate() {
    return isWidePlate;
    }

    public void setWidePlate(boolean isWidePlate) {
    this.isWidePlate = isWidePlate;
    }

    public Mat getImage() {
    return plateImage;
    }

    public void setImage(Mat Bitmap) {
    plateImage = Bitmap;
    }

    public Bitmap getForCutImageIcon() {
    if (forCutImageIcon == null) {
    forCutImageIcon = IPHelper.matToBitmap(forCut);
    }
    return forCutImageIcon;
    }

    public Mat getForCut() {
    return forCut;
    }

    public void setForCutImageIcon(Bitmap forCutImageIcon) {
    this.forCutImageIcon = forCutImageIcon;
    }

    public void setForCut(Mat forCut) {
    this.forCut = forCut;
    }

    public ArrayList<Character> getPlateNumberChar() {
    return plateNumberChars;
    }

    public void setPlateNumberChar(ArrayList<Character> nchar) {
    plateNumberChars = new ArrayList<Character>(nchar);
    }

    public char getPlateLetter() {
    return plateLetterChar;
    }

    public void setPlateLetter(char plateLetter) {
    plateLetterChar = plateLetter;
    }

    public int getId() {
    return id;
    }

    public void setId(int id) {
    this.id = id;
    }

    public double getLetterRate() {
    return letterRate;
    }

    public void setLetterRate(double letterRate) {
    this.letterRate = letterRate;
    }

    public double getCharsRate() {
    return numbersRate;
    }

    public void setNumbersRate(double NumbersRate) {
    this.numbersRate = NumbersRate;
    }

    public double getAccuracy() {
    return accuracy;
    }

    public int getAccurayPercent() {
    return accurayPercent;
    }

    public void setAccuracy(double totalRate) {
    this.accuracy = totalRate;
    this.accurayPercent = (int) (totalRate * 100);
    }

    public Mat getPlateImage() {
    return plateImage;
    }

    public void setPlateImage(Mat matImage) {
    this.plateImage = matImage;
    plateImageIcon = IPHelper.matToBitmap(matImage);
    }

    public PlateRecogInfo getPlateRecogInfo() {
    return plateRecogInfo;
    }

    public void setPlateRecogInfo(PlateRecogInfo plateRecogInfo) {
    this.plateRecogInfo = plateRecogInfo;
    }

    public void addCharIcon(Mat charsIcons) {
    this.charsIcons.add(IPHelper.matToBitmap(charsIcons));
    }

    public Bitmap getcharsImageIcon() {
    if (charsImageIcon == null) {
    int width = 5;
    int height = 0;
    for (Bitmap icon : charsIcons) {
    if (icon.getHeight() > height)
    height = icon.getHeight();
    width += icon.getWidth() + 5;
    }
    height += 6;

    charsImageIcon = Bitmap.createBitmap(width, height, Bitmap.Config.ARGB_8888);
    Canvas canvas = new Canvas(charsImageIcon);

    int i = 0;
    for (Bitmap icon : charsIcons) {
    canvas.drawBitmap(icon, i, 3, null);
    i += icon.getWidth() + 5;
    }
    }

    return charsImageIcon;
    }

    public Bitmap getCharsTextImageIcon() {
    if (charsTextImageIcon == null) {
    String chars = "";
    for (Character c : plateNumberChars) {
    String cs = c.toString();
    chars += cs;
    }

    int width = 5;
    int height = 0;
    for (Bitmap icon : charsIcons) {
    if (icon.getHeight() > height)
    height = icon.getHeight();
    width += icon.getWidth() + 5;
    }
    height += 6;

    charsTextImageIcon = Bitmap.createBitmap(width, height, Bitmap.Config.ARGB_8888);
    Canvas canvas = new Canvas(charsTextImageIcon);

    int i = 0;
    int j = 0;

    Paint paint = new Paint(Paint.ANTI_ALIAS_FLAG);
    paint.setTypeface(Typeface.create(Typeface.DEFAULT, Typeface.BOLD));
    paint.setColor(Color.BLACK);
    paint.setTextSize(16);

    canvas.drawColor(Color.WHITE);

    for (Bitmap icon : charsIcons) {

    if (j == 0)
    canvas.drawText("Some Text", i + 2, 19, paint);
    else
    canvas.drawText(Character.toString(chars.charAt(j - 1)), i + 3, 19, paint);

    i += icon.getWidth() + 5;
    j++;
    }

    }

    return charsTextImageIcon;
    }

    public void setCharsTextImageIcon(Bitmap charsTextImageIcon) {
    this.charsTextImageIcon = charsTextImageIcon;
    }

    public Mat getSrcImage() {
    return srcImage;
    }

    public void setSrcImage(Mat srcImage) {
    this.srcImage = srcImage;
    }

    public Rect getBdgbx() {
    return bdgbx;
    }

    public void setBdgbx(Rect bdgbx) {
    this.bdgbx = bdgbx;
    }

    public int getColor() {
    return color;
    }

    // public Color getColorObject() {
    // int color = getColor();
    //
    // try {
    // return Color.parseColor(Color.rgb(color[0], color[1], color[2]));
    // } catch (Exception e) {
    // }
    // return null;
    // }

    public void setColor(int is) {
    this.color = is;
    }

    public String getColorString() {
    return colorString;
    }

    public void setColorString(String colorString) {
    this.colorString = colorString;
    }

    public String getFullPlateCharsString() {
    if (fullPlateString == "" || fullPlateString == null) {
    fullPlateString += plateLetterChar;
    for (Character c : plateNumberChars) {
    fullPlateString += c.toString();
    }
    }

    return fullPlateString;
    }

    public void setFullPlateString(String fullPlateString) {
    this.fullPlateString = fullPlateString;
    }

    public void setNumbersPlateString(String numbersPslateString) {
    this.numbersPlateString = numbersPslateString;
    }

    public String getPlateNumbersAsString() {
    if (numbersPlateString == "" || numbersPlateString == null) {
    for (Character c : plateNumberChars) {
    numbersPlateString += c.toString();
    }
    }

    return numbersPlateString;
    }

    public String getPlatePath() {
    return platePath;
    }

    public void setPlatePath(String platePath) {
    this.platePath = platePath;
    }

    public boolean isIgnore() {
    return ignore;
    }

    public void setIgnore(boolean ignore) {
    this.ignore = ignore;
    }

    public String getSource() {
    return source;
    }

    public void setSource(String source) {
    this.source = source;
    }

    }


    Usage:



    PlateListAdapter plateListAdapter = new PlateListAdapter(getApplicationContext(), R.layout.list_item);
    ListView resultsListView = (ListView) findViewById(R.id.lvExp);
    resultsListView.setAdapter(plateListAdapter);
    plateListAdapter.addAll(recogInfo.getPlates());
    plateListAdapter.notifyDataSetChanged();









    share|improve this question



























      0












      0








      0







      I have a ListView, inside a linear layout, that should show items based on a list_item.xml layout file. In the layout file I have two ImageViews and two TextViews. I'm using my custom ArrayAdapter to fill the ListView at runtime with Bitmap images of scale 125x25, however images are showing smaller than their initial size when rendered by the ImageView inside the ListView as shown in the screenshot (of a single list item) below:



      enter image description here



      ActivityLayout.xml:



      ...
      <LinearLayout
      android:layout_width="match_parent"
      android:layout_height="match_parent"
      android:layout_alignParentStart="true"
      android:paddingTop="40dp"
      android:orientation="vertical">

      <ListView
      android:id="@+id/lvExp"
      android:layout_width="match_parent"
      android:layout_height="match_parent" />

      </LinearLayout>
      ...


      List_item.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:minHeight="?android:attr/listPreferredItemHeight">

      <ImageView
      android:id="@+id/imageViewplate"
      android:layout_width="wrap_content"
      android:layout_height="match_parent"
      android:layout_alignParentLeft="true"
      android:adjustViewBounds="true"
      android:minWidth="300dp" />

      <TextView
      android:id="@+id/lblListItem_letter"
      android:layout_width="wrap_content"
      android:layout_height="match_parent"
      android:layout_marginLeft="10dp"
      android:layout_toRightOf="@id/imageViewplate"
      android:padding="3dp"
      android:text="A"
      android:textSize="17dip" />

      <TextView
      android:id="@+id/lblListItem_num"
      android:layout_width="wrap_content"
      android:layout_height="match_parent"
      android:layout_marginLeft="10dp"
      android:layout_toRightOf="@id/lblListItem_letter"
      android:padding="3dp"
      android:text="123456"
      android:textSize="17dip" />

      <ImageView
      android:id="@+id/imageViewchars"
      android:layout_width="wrap_content"
      android:layout_height="match_parent"
      android:layout_alignParentRight="true"
      android:layout_alignParentBottom="true"
      android:layout_marginLeft="10dp"
      android:paddingTop="3dp"
      android:paddingBottom="3dp" />

      </RelativeLayout>


      My custom list adapter:



          package bi.anpr.layouts;

      import android.content.Context;
      import android.support.design.widget.Snackbar;
      import android.view.LayoutInflater;
      import android.view.View;
      import android.view.ViewGroup;
      import android.widget.ArrayAdapter;
      import android.widget.ImageView;
      import android.widget.TextView;

      import com.sxx.vlctest.R;

      import java.util.ArrayList;

      import bi.anpr.agents.Plate;

      public class PlateListAdapter extends ArrayAdapter<Plate>{

      public PlateListAdapter(Context context, int resource) {
      super(context, resource);
      }

      private ArrayList<Plate> dataSet;
      Context mContext;

      private static class ViewHolder {
      public ImageView imageView_plate, imageView_chars;
      public TextView textView_letter, textView_numbers;
      }

      private int lastPosition = -1;

      @Override
      public View getView(int position, View convertView, ViewGroup parent) {
      // Get the data item for this position
      Plate plate = getItem(position);
      ViewHolder viewHolder;
      final View result;

      if (convertView == null) {
      viewHolder = new ViewHolder();

      LayoutInflater inflater = LayoutInflater.from(getContext());
      convertView = inflater.inflate(R.layout.list_item, parent, false);

      viewHolder.textView_letter = (TextView) convertView.findViewById(R.id.lblListItem_letter);
      viewHolder.textView_numbers = (TextView) convertView.findViewById(R.id.lblListItem_num);
      viewHolder.imageView_plate = (ImageView) convertView.findViewById(R.id.imageViewplate);
      viewHolder.imageView_chars = (ImageView) convertView.findViewById(R.id.imageViewchars);
      result = convertView;

      convertView.setTag(viewHolder);
      } else {
      viewHolder = (ViewHolder) convertView.getTag();
      result = convertView;
      }

      lastPosition = position;

      try{
      viewHolder.imageView_plate.setImageBitmap(plate.getEngPartImageIcon());
      viewHolder.imageView_chars.setImageBitmap(plate.getcharsImageIcon());
      viewHolder.textView_letter.setText(Character.toString(plate.getPlateLetter()));
      viewHolder.textView_numbers.setText(plate.getPlateNumbersAsString());
      }catch (Exception e){
      e.printStackTrace();
      }


      // Return the completed view to render on screen
      return convertView;
      }
      }


      Plate.java:



      package bi.anpr.agents;

      import android.graphics.Bitmap;
      import android.graphics.Canvas;
      import android.graphics.Color;
      import android.graphics.Paint;
      import android.graphics.Typeface;

      import java.io.Serializable;
      import java.util.ArrayList;


      import org.opencv.core.Mat;
      import org.opencv.core.Rect;

      import bi.anpr.core.IPHelper;

      public class Plate implements Serializable {

      private String platePath;
      private boolean isWidePlate = true;
      private int color;
      private String colorString;
      private String source = "";
      private Rect bdgbx;
      private Mat srcImage;
      private Mat plateImage;
      private Bitmap engPartImageIcon, plateImageIcon, forCutImageIcon, charsImageIcon, charsTextImageIcon;
      private Mat engPartImage;
      private Mat forCut;
      private ArrayList<Character> plateNumberChars = new ArrayList<>();
      private char plateLetterChar = '#';
      private String fullPlateString = "";
      private String numbersPlateString = "";
      private double letterRate = 0;
      private double numbersRate = 0;
      private double accuracy = 0;
      private int id;
      private PlateRecogInfo plateRecogInfo;
      private ArrayList<Bitmap> charsIcons = new ArrayList<>();
      private boolean ignore = false;
      private int accurayPercent = 0;

      public Plate() {
      plateRecogInfo = new PlateRecogInfo();
      }

      public void addPlateNumberChar(char c) {
      plateNumberChars.add(c);
      }

      public Bitmap getplateImageIcon() {
      return plateImageIcon;
      }

      public void setPlateImageIcon(Bitmap plateImageIcon) {
      this.plateImageIcon = plateImageIcon;
      }

      public Bitmap getEngPartImageIcon() {
      if (engPartImageIcon == null) {
      engPartImageIcon = IPHelper.matToBitmap(engPartImage);
      }
      return engPartImageIcon;
      }

      public void setEngPartImageIcon(Bitmap engPartImageIcon) {
      this.engPartImageIcon = engPartImageIcon;
      }

      public Mat getEngPartImage() {
      return engPartImage;
      }

      public void setEngPartImage(Mat engPartImage) {
      this.engPartImage = engPartImage;
      }

      public boolean isWidePlate() {
      return isWidePlate;
      }

      public void setWidePlate(boolean isWidePlate) {
      this.isWidePlate = isWidePlate;
      }

      public Mat getImage() {
      return plateImage;
      }

      public void setImage(Mat Bitmap) {
      plateImage = Bitmap;
      }

      public Bitmap getForCutImageIcon() {
      if (forCutImageIcon == null) {
      forCutImageIcon = IPHelper.matToBitmap(forCut);
      }
      return forCutImageIcon;
      }

      public Mat getForCut() {
      return forCut;
      }

      public void setForCutImageIcon(Bitmap forCutImageIcon) {
      this.forCutImageIcon = forCutImageIcon;
      }

      public void setForCut(Mat forCut) {
      this.forCut = forCut;
      }

      public ArrayList<Character> getPlateNumberChar() {
      return plateNumberChars;
      }

      public void setPlateNumberChar(ArrayList<Character> nchar) {
      plateNumberChars = new ArrayList<Character>(nchar);
      }

      public char getPlateLetter() {
      return plateLetterChar;
      }

      public void setPlateLetter(char plateLetter) {
      plateLetterChar = plateLetter;
      }

      public int getId() {
      return id;
      }

      public void setId(int id) {
      this.id = id;
      }

      public double getLetterRate() {
      return letterRate;
      }

      public void setLetterRate(double letterRate) {
      this.letterRate = letterRate;
      }

      public double getCharsRate() {
      return numbersRate;
      }

      public void setNumbersRate(double NumbersRate) {
      this.numbersRate = NumbersRate;
      }

      public double getAccuracy() {
      return accuracy;
      }

      public int getAccurayPercent() {
      return accurayPercent;
      }

      public void setAccuracy(double totalRate) {
      this.accuracy = totalRate;
      this.accurayPercent = (int) (totalRate * 100);
      }

      public Mat getPlateImage() {
      return plateImage;
      }

      public void setPlateImage(Mat matImage) {
      this.plateImage = matImage;
      plateImageIcon = IPHelper.matToBitmap(matImage);
      }

      public PlateRecogInfo getPlateRecogInfo() {
      return plateRecogInfo;
      }

      public void setPlateRecogInfo(PlateRecogInfo plateRecogInfo) {
      this.plateRecogInfo = plateRecogInfo;
      }

      public void addCharIcon(Mat charsIcons) {
      this.charsIcons.add(IPHelper.matToBitmap(charsIcons));
      }

      public Bitmap getcharsImageIcon() {
      if (charsImageIcon == null) {
      int width = 5;
      int height = 0;
      for (Bitmap icon : charsIcons) {
      if (icon.getHeight() > height)
      height = icon.getHeight();
      width += icon.getWidth() + 5;
      }
      height += 6;

      charsImageIcon = Bitmap.createBitmap(width, height, Bitmap.Config.ARGB_8888);
      Canvas canvas = new Canvas(charsImageIcon);

      int i = 0;
      for (Bitmap icon : charsIcons) {
      canvas.drawBitmap(icon, i, 3, null);
      i += icon.getWidth() + 5;
      }
      }

      return charsImageIcon;
      }

      public Bitmap getCharsTextImageIcon() {
      if (charsTextImageIcon == null) {
      String chars = "";
      for (Character c : plateNumberChars) {
      String cs = c.toString();
      chars += cs;
      }

      int width = 5;
      int height = 0;
      for (Bitmap icon : charsIcons) {
      if (icon.getHeight() > height)
      height = icon.getHeight();
      width += icon.getWidth() + 5;
      }
      height += 6;

      charsTextImageIcon = Bitmap.createBitmap(width, height, Bitmap.Config.ARGB_8888);
      Canvas canvas = new Canvas(charsTextImageIcon);

      int i = 0;
      int j = 0;

      Paint paint = new Paint(Paint.ANTI_ALIAS_FLAG);
      paint.setTypeface(Typeface.create(Typeface.DEFAULT, Typeface.BOLD));
      paint.setColor(Color.BLACK);
      paint.setTextSize(16);

      canvas.drawColor(Color.WHITE);

      for (Bitmap icon : charsIcons) {

      if (j == 0)
      canvas.drawText("Some Text", i + 2, 19, paint);
      else
      canvas.drawText(Character.toString(chars.charAt(j - 1)), i + 3, 19, paint);

      i += icon.getWidth() + 5;
      j++;
      }

      }

      return charsTextImageIcon;
      }

      public void setCharsTextImageIcon(Bitmap charsTextImageIcon) {
      this.charsTextImageIcon = charsTextImageIcon;
      }

      public Mat getSrcImage() {
      return srcImage;
      }

      public void setSrcImage(Mat srcImage) {
      this.srcImage = srcImage;
      }

      public Rect getBdgbx() {
      return bdgbx;
      }

      public void setBdgbx(Rect bdgbx) {
      this.bdgbx = bdgbx;
      }

      public int getColor() {
      return color;
      }

      // public Color getColorObject() {
      // int color = getColor();
      //
      // try {
      // return Color.parseColor(Color.rgb(color[0], color[1], color[2]));
      // } catch (Exception e) {
      // }
      // return null;
      // }

      public void setColor(int is) {
      this.color = is;
      }

      public String getColorString() {
      return colorString;
      }

      public void setColorString(String colorString) {
      this.colorString = colorString;
      }

      public String getFullPlateCharsString() {
      if (fullPlateString == "" || fullPlateString == null) {
      fullPlateString += plateLetterChar;
      for (Character c : plateNumberChars) {
      fullPlateString += c.toString();
      }
      }

      return fullPlateString;
      }

      public void setFullPlateString(String fullPlateString) {
      this.fullPlateString = fullPlateString;
      }

      public void setNumbersPlateString(String numbersPslateString) {
      this.numbersPlateString = numbersPslateString;
      }

      public String getPlateNumbersAsString() {
      if (numbersPlateString == "" || numbersPlateString == null) {
      for (Character c : plateNumberChars) {
      numbersPlateString += c.toString();
      }
      }

      return numbersPlateString;
      }

      public String getPlatePath() {
      return platePath;
      }

      public void setPlatePath(String platePath) {
      this.platePath = platePath;
      }

      public boolean isIgnore() {
      return ignore;
      }

      public void setIgnore(boolean ignore) {
      this.ignore = ignore;
      }

      public String getSource() {
      return source;
      }

      public void setSource(String source) {
      this.source = source;
      }

      }


      Usage:



      PlateListAdapter plateListAdapter = new PlateListAdapter(getApplicationContext(), R.layout.list_item);
      ListView resultsListView = (ListView) findViewById(R.id.lvExp);
      resultsListView.setAdapter(plateListAdapter);
      plateListAdapter.addAll(recogInfo.getPlates());
      plateListAdapter.notifyDataSetChanged();









      share|improve this question















      I have a ListView, inside a linear layout, that should show items based on a list_item.xml layout file. In the layout file I have two ImageViews and two TextViews. I'm using my custom ArrayAdapter to fill the ListView at runtime with Bitmap images of scale 125x25, however images are showing smaller than their initial size when rendered by the ImageView inside the ListView as shown in the screenshot (of a single list item) below:



      enter image description here



      ActivityLayout.xml:



      ...
      <LinearLayout
      android:layout_width="match_parent"
      android:layout_height="match_parent"
      android:layout_alignParentStart="true"
      android:paddingTop="40dp"
      android:orientation="vertical">

      <ListView
      android:id="@+id/lvExp"
      android:layout_width="match_parent"
      android:layout_height="match_parent" />

      </LinearLayout>
      ...


      List_item.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:minHeight="?android:attr/listPreferredItemHeight">

      <ImageView
      android:id="@+id/imageViewplate"
      android:layout_width="wrap_content"
      android:layout_height="match_parent"
      android:layout_alignParentLeft="true"
      android:adjustViewBounds="true"
      android:minWidth="300dp" />

      <TextView
      android:id="@+id/lblListItem_letter"
      android:layout_width="wrap_content"
      android:layout_height="match_parent"
      android:layout_marginLeft="10dp"
      android:layout_toRightOf="@id/imageViewplate"
      android:padding="3dp"
      android:text="A"
      android:textSize="17dip" />

      <TextView
      android:id="@+id/lblListItem_num"
      android:layout_width="wrap_content"
      android:layout_height="match_parent"
      android:layout_marginLeft="10dp"
      android:layout_toRightOf="@id/lblListItem_letter"
      android:padding="3dp"
      android:text="123456"
      android:textSize="17dip" />

      <ImageView
      android:id="@+id/imageViewchars"
      android:layout_width="wrap_content"
      android:layout_height="match_parent"
      android:layout_alignParentRight="true"
      android:layout_alignParentBottom="true"
      android:layout_marginLeft="10dp"
      android:paddingTop="3dp"
      android:paddingBottom="3dp" />

      </RelativeLayout>


      My custom list adapter:



          package bi.anpr.layouts;

      import android.content.Context;
      import android.support.design.widget.Snackbar;
      import android.view.LayoutInflater;
      import android.view.View;
      import android.view.ViewGroup;
      import android.widget.ArrayAdapter;
      import android.widget.ImageView;
      import android.widget.TextView;

      import com.sxx.vlctest.R;

      import java.util.ArrayList;

      import bi.anpr.agents.Plate;

      public class PlateListAdapter extends ArrayAdapter<Plate>{

      public PlateListAdapter(Context context, int resource) {
      super(context, resource);
      }

      private ArrayList<Plate> dataSet;
      Context mContext;

      private static class ViewHolder {
      public ImageView imageView_plate, imageView_chars;
      public TextView textView_letter, textView_numbers;
      }

      private int lastPosition = -1;

      @Override
      public View getView(int position, View convertView, ViewGroup parent) {
      // Get the data item for this position
      Plate plate = getItem(position);
      ViewHolder viewHolder;
      final View result;

      if (convertView == null) {
      viewHolder = new ViewHolder();

      LayoutInflater inflater = LayoutInflater.from(getContext());
      convertView = inflater.inflate(R.layout.list_item, parent, false);

      viewHolder.textView_letter = (TextView) convertView.findViewById(R.id.lblListItem_letter);
      viewHolder.textView_numbers = (TextView) convertView.findViewById(R.id.lblListItem_num);
      viewHolder.imageView_plate = (ImageView) convertView.findViewById(R.id.imageViewplate);
      viewHolder.imageView_chars = (ImageView) convertView.findViewById(R.id.imageViewchars);
      result = convertView;

      convertView.setTag(viewHolder);
      } else {
      viewHolder = (ViewHolder) convertView.getTag();
      result = convertView;
      }

      lastPosition = position;

      try{
      viewHolder.imageView_plate.setImageBitmap(plate.getEngPartImageIcon());
      viewHolder.imageView_chars.setImageBitmap(plate.getcharsImageIcon());
      viewHolder.textView_letter.setText(Character.toString(plate.getPlateLetter()));
      viewHolder.textView_numbers.setText(plate.getPlateNumbersAsString());
      }catch (Exception e){
      e.printStackTrace();
      }


      // Return the completed view to render on screen
      return convertView;
      }
      }


      Plate.java:



      package bi.anpr.agents;

      import android.graphics.Bitmap;
      import android.graphics.Canvas;
      import android.graphics.Color;
      import android.graphics.Paint;
      import android.graphics.Typeface;

      import java.io.Serializable;
      import java.util.ArrayList;


      import org.opencv.core.Mat;
      import org.opencv.core.Rect;

      import bi.anpr.core.IPHelper;

      public class Plate implements Serializable {

      private String platePath;
      private boolean isWidePlate = true;
      private int color;
      private String colorString;
      private String source = "";
      private Rect bdgbx;
      private Mat srcImage;
      private Mat plateImage;
      private Bitmap engPartImageIcon, plateImageIcon, forCutImageIcon, charsImageIcon, charsTextImageIcon;
      private Mat engPartImage;
      private Mat forCut;
      private ArrayList<Character> plateNumberChars = new ArrayList<>();
      private char plateLetterChar = '#';
      private String fullPlateString = "";
      private String numbersPlateString = "";
      private double letterRate = 0;
      private double numbersRate = 0;
      private double accuracy = 0;
      private int id;
      private PlateRecogInfo plateRecogInfo;
      private ArrayList<Bitmap> charsIcons = new ArrayList<>();
      private boolean ignore = false;
      private int accurayPercent = 0;

      public Plate() {
      plateRecogInfo = new PlateRecogInfo();
      }

      public void addPlateNumberChar(char c) {
      plateNumberChars.add(c);
      }

      public Bitmap getplateImageIcon() {
      return plateImageIcon;
      }

      public void setPlateImageIcon(Bitmap plateImageIcon) {
      this.plateImageIcon = plateImageIcon;
      }

      public Bitmap getEngPartImageIcon() {
      if (engPartImageIcon == null) {
      engPartImageIcon = IPHelper.matToBitmap(engPartImage);
      }
      return engPartImageIcon;
      }

      public void setEngPartImageIcon(Bitmap engPartImageIcon) {
      this.engPartImageIcon = engPartImageIcon;
      }

      public Mat getEngPartImage() {
      return engPartImage;
      }

      public void setEngPartImage(Mat engPartImage) {
      this.engPartImage = engPartImage;
      }

      public boolean isWidePlate() {
      return isWidePlate;
      }

      public void setWidePlate(boolean isWidePlate) {
      this.isWidePlate = isWidePlate;
      }

      public Mat getImage() {
      return plateImage;
      }

      public void setImage(Mat Bitmap) {
      plateImage = Bitmap;
      }

      public Bitmap getForCutImageIcon() {
      if (forCutImageIcon == null) {
      forCutImageIcon = IPHelper.matToBitmap(forCut);
      }
      return forCutImageIcon;
      }

      public Mat getForCut() {
      return forCut;
      }

      public void setForCutImageIcon(Bitmap forCutImageIcon) {
      this.forCutImageIcon = forCutImageIcon;
      }

      public void setForCut(Mat forCut) {
      this.forCut = forCut;
      }

      public ArrayList<Character> getPlateNumberChar() {
      return plateNumberChars;
      }

      public void setPlateNumberChar(ArrayList<Character> nchar) {
      plateNumberChars = new ArrayList<Character>(nchar);
      }

      public char getPlateLetter() {
      return plateLetterChar;
      }

      public void setPlateLetter(char plateLetter) {
      plateLetterChar = plateLetter;
      }

      public int getId() {
      return id;
      }

      public void setId(int id) {
      this.id = id;
      }

      public double getLetterRate() {
      return letterRate;
      }

      public void setLetterRate(double letterRate) {
      this.letterRate = letterRate;
      }

      public double getCharsRate() {
      return numbersRate;
      }

      public void setNumbersRate(double NumbersRate) {
      this.numbersRate = NumbersRate;
      }

      public double getAccuracy() {
      return accuracy;
      }

      public int getAccurayPercent() {
      return accurayPercent;
      }

      public void setAccuracy(double totalRate) {
      this.accuracy = totalRate;
      this.accurayPercent = (int) (totalRate * 100);
      }

      public Mat getPlateImage() {
      return plateImage;
      }

      public void setPlateImage(Mat matImage) {
      this.plateImage = matImage;
      plateImageIcon = IPHelper.matToBitmap(matImage);
      }

      public PlateRecogInfo getPlateRecogInfo() {
      return plateRecogInfo;
      }

      public void setPlateRecogInfo(PlateRecogInfo plateRecogInfo) {
      this.plateRecogInfo = plateRecogInfo;
      }

      public void addCharIcon(Mat charsIcons) {
      this.charsIcons.add(IPHelper.matToBitmap(charsIcons));
      }

      public Bitmap getcharsImageIcon() {
      if (charsImageIcon == null) {
      int width = 5;
      int height = 0;
      for (Bitmap icon : charsIcons) {
      if (icon.getHeight() > height)
      height = icon.getHeight();
      width += icon.getWidth() + 5;
      }
      height += 6;

      charsImageIcon = Bitmap.createBitmap(width, height, Bitmap.Config.ARGB_8888);
      Canvas canvas = new Canvas(charsImageIcon);

      int i = 0;
      for (Bitmap icon : charsIcons) {
      canvas.drawBitmap(icon, i, 3, null);
      i += icon.getWidth() + 5;
      }
      }

      return charsImageIcon;
      }

      public Bitmap getCharsTextImageIcon() {
      if (charsTextImageIcon == null) {
      String chars = "";
      for (Character c : plateNumberChars) {
      String cs = c.toString();
      chars += cs;
      }

      int width = 5;
      int height = 0;
      for (Bitmap icon : charsIcons) {
      if (icon.getHeight() > height)
      height = icon.getHeight();
      width += icon.getWidth() + 5;
      }
      height += 6;

      charsTextImageIcon = Bitmap.createBitmap(width, height, Bitmap.Config.ARGB_8888);
      Canvas canvas = new Canvas(charsTextImageIcon);

      int i = 0;
      int j = 0;

      Paint paint = new Paint(Paint.ANTI_ALIAS_FLAG);
      paint.setTypeface(Typeface.create(Typeface.DEFAULT, Typeface.BOLD));
      paint.setColor(Color.BLACK);
      paint.setTextSize(16);

      canvas.drawColor(Color.WHITE);

      for (Bitmap icon : charsIcons) {

      if (j == 0)
      canvas.drawText("Some Text", i + 2, 19, paint);
      else
      canvas.drawText(Character.toString(chars.charAt(j - 1)), i + 3, 19, paint);

      i += icon.getWidth() + 5;
      j++;
      }

      }

      return charsTextImageIcon;
      }

      public void setCharsTextImageIcon(Bitmap charsTextImageIcon) {
      this.charsTextImageIcon = charsTextImageIcon;
      }

      public Mat getSrcImage() {
      return srcImage;
      }

      public void setSrcImage(Mat srcImage) {
      this.srcImage = srcImage;
      }

      public Rect getBdgbx() {
      return bdgbx;
      }

      public void setBdgbx(Rect bdgbx) {
      this.bdgbx = bdgbx;
      }

      public int getColor() {
      return color;
      }

      // public Color getColorObject() {
      // int color = getColor();
      //
      // try {
      // return Color.parseColor(Color.rgb(color[0], color[1], color[2]));
      // } catch (Exception e) {
      // }
      // return null;
      // }

      public void setColor(int is) {
      this.color = is;
      }

      public String getColorString() {
      return colorString;
      }

      public void setColorString(String colorString) {
      this.colorString = colorString;
      }

      public String getFullPlateCharsString() {
      if (fullPlateString == "" || fullPlateString == null) {
      fullPlateString += plateLetterChar;
      for (Character c : plateNumberChars) {
      fullPlateString += c.toString();
      }
      }

      return fullPlateString;
      }

      public void setFullPlateString(String fullPlateString) {
      this.fullPlateString = fullPlateString;
      }

      public void setNumbersPlateString(String numbersPslateString) {
      this.numbersPlateString = numbersPslateString;
      }

      public String getPlateNumbersAsString() {
      if (numbersPlateString == "" || numbersPlateString == null) {
      for (Character c : plateNumberChars) {
      numbersPlateString += c.toString();
      }
      }

      return numbersPlateString;
      }

      public String getPlatePath() {
      return platePath;
      }

      public void setPlatePath(String platePath) {
      this.platePath = platePath;
      }

      public boolean isIgnore() {
      return ignore;
      }

      public void setIgnore(boolean ignore) {
      this.ignore = ignore;
      }

      public String getSource() {
      return source;
      }

      public void setSource(String source) {
      this.source = source;
      }

      }


      Usage:



      PlateListAdapter plateListAdapter = new PlateListAdapter(getApplicationContext(), R.layout.list_item);
      ListView resultsListView = (ListView) findViewById(R.id.lvExp);
      resultsListView.setAdapter(plateListAdapter);
      plateListAdapter.addAll(recogInfo.getPlates());
      plateListAdapter.notifyDataSetChanged();






      android android-layout listview android-listview expandablelistview






      share|improve this question















      share|improve this question













      share|improve this question




      share|improve this question








      edited Nov 22 '18 at 9:25









      Ali Khaki

      7251418




      7251418










      asked Nov 21 '18 at 14:47









      peter bence

      5510




      5510
























          1 Answer
          1






          active

          oldest

          votes


















          0














          Using definite dimensions for ImageView's, rather than wrap_content solved the problem.






          share|improve this answer





















            Your Answer






            StackExchange.ifUsing("editor", function () {
            StackExchange.using("externalEditor", function () {
            StackExchange.using("snippets", function () {
            StackExchange.snippets.init();
            });
            });
            }, "code-snippets");

            StackExchange.ready(function() {
            var channelOptions = {
            tags: "".split(" "),
            id: "1"
            };
            initTagRenderer("".split(" "), "".split(" "), channelOptions);

            StackExchange.using("externalEditor", function() {
            // Have to fire editor after snippets, if snippets enabled
            if (StackExchange.settings.snippets.snippetsEnabled) {
            StackExchange.using("snippets", function() {
            createEditor();
            });
            }
            else {
            createEditor();
            }
            });

            function createEditor() {
            StackExchange.prepareEditor({
            heartbeatType: 'answer',
            autoActivateHeartbeat: false,
            convertImagesToLinks: true,
            noModals: true,
            showLowRepImageUploadWarning: true,
            reputationToPostImages: 10,
            bindNavPrevention: true,
            postfix: "",
            imageUploader: {
            brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
            contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
            allowUrls: true
            },
            onDemand: true,
            discardSelector: ".discard-answer"
            ,immediatelyShowMarkdownHelp:true
            });


            }
            });














            draft saved

            draft discarded


















            StackExchange.ready(
            function () {
            StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53414597%2fandroid-imageview-is-rendering-bitmap-images-smaller-while-in-listview%23new-answer', 'question_page');
            }
            );

            Post as a guest















            Required, but never shown

























            1 Answer
            1






            active

            oldest

            votes








            1 Answer
            1






            active

            oldest

            votes









            active

            oldest

            votes






            active

            oldest

            votes









            0














            Using definite dimensions for ImageView's, rather than wrap_content solved the problem.






            share|improve this answer


























              0














              Using definite dimensions for ImageView's, rather than wrap_content solved the problem.






              share|improve this answer
























                0












                0








                0






                Using definite dimensions for ImageView's, rather than wrap_content solved the problem.






                share|improve this answer












                Using definite dimensions for ImageView's, rather than wrap_content solved the problem.







                share|improve this answer












                share|improve this answer



                share|improve this answer










                answered Dec 3 '18 at 14:21









                peter bence

                5510




                5510






























                    draft saved

                    draft discarded




















































                    Thanks for contributing an answer to Stack Overflow!


                    • Please be sure to answer the question. Provide details and share your research!

                    But avoid



                    • Asking for help, clarification, or responding to other answers.

                    • Making statements based on opinion; back them up with references or personal experience.


                    To learn more, see our tips on writing great answers.





                    Some of your past answers have not been well-received, and you're in danger of being blocked from answering.


                    Please pay close attention to the following guidance:


                    • Please be sure to answer the question. Provide details and share your research!

                    But avoid



                    • Asking for help, clarification, or responding to other answers.

                    • Making statements based on opinion; back them up with references or personal experience.


                    To learn more, see our tips on writing great answers.




                    draft saved


                    draft discarded














                    StackExchange.ready(
                    function () {
                    StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53414597%2fandroid-imageview-is-rendering-bitmap-images-smaller-while-in-listview%23new-answer', 'question_page');
                    }
                    );

                    Post as a guest















                    Required, but never shown





















































                    Required, but never shown














                    Required, but never shown












                    Required, but never shown







                    Required, but never shown

































                    Required, but never shown














                    Required, but never shown












                    Required, but never shown







                    Required, but never shown







                    Popular posts from this blog

                    404 Error Contact Form 7 ajax form submitting

                    How to know if a Active Directory user can login interactively

                    Refactoring coordinates for Minecraft Pi buildings written in Python