There Fragment. Is it RecyclerView attached below. The bottom line is that by design is the first element should take a little more space than the others. His I increase in ViewHolder of the adapter when rendering as follows:
public class myAdapter extends RecyclerView.Adapter ...
...
#Override
public void onBindViewHolder(final ViewHolder holder, final int position) {
WeatherForDay weather = mWeathersList.get(position);
holder.mDayTextView.setText(weather.getDay());
//todo update iconManager
//need icon manager, with input -> String, output ->(R.drawable.icon) int
holder.mIconImageView.setImageResource(R.drawable.testicon1);
holder.mTempTextView.setText(weather.getTmp());
if (position == 0) {
if (isFirstBind) {
Log.d(DEBUG_TAG, "is first bind and first position");
holder.setBig();
isFirstBind = false;
}
}
}
...
public void setBig() {
LinearLayout.LayoutParams param = (LinearLayout.LayoutParams) mRoundLayout.getLayoutParams();
int newHeight = (int) (param.height * 1.2f);
int newWidth = (int) (param.height * 1.2f);
param.height = newHeight;
param.width = newWidth;
mRoundLayout.setLayoutParams(param);
mRoundLayout.setBackgroundDrawable(createBigShape(newHeight));
}
private Drawable createBigShape(int newHW) {
GradientDrawable shape = new GradientDrawable();
shape.setShape(GradientDrawable.RECTANGLE);
shape.setCornerRadii(new float[]{newHW, newHW, newHW, newHW, newHW, newHW, newHW, newHW});
shape.setColor(mContext.getResources().getColor(R.color.weryDark));
shape.setStroke(1, mContext.getResources().getColor(R.color.weryDark));
return shape;
}
...
}
How to make elements are aligned along the upper edge and the lower?
P.S. The same problem arises in that the N-element also somehow rendered "large" (on the same device with a large screen N = 13, on the small screen N = 8)
P.S.2 Can eat what is more optimal way to change any element RecyclerView?
item_recycler.xml
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginLeft="4dp"
android:layout_marginRight="4dp"
android:gravity="center_horizontal"
android:orientation="vertical">
<TextView
android:id="#+id/day_text_view_list_item_bottom"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textColor="#color/colorWhite"
android:background="#null"/>
<LinearLayout
android:id="#+id/rounded_linear_layout"
android:layout_width="80dp"
android:layout_height="80dp"
android:background="#drawable/round_shape"
android:gravity="center_horizontal"
android:orientation="vertical">
<android.support.v7.widget.AppCompatImageView
android:id="#+id/icon_image_view_list_item_bottom"
android:layout_width="42dp"
android:layout_height="42dp"
android:background="#null"
app:srcCompat="#drawable/testicon1"
tools:ignore="MissingPrefix"/>
<TextView
android:id="#+id/temperature_text_view_list_item_bottom"
android:textColor="#color/colorWhite"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textSize="16sp"
android:textStyle="bold"/>
</LinearLayout>
</LinearLayout>
For the gravity issue:
You have to set android:layout_gravity="center_vertical" or android:layout_gravity="center" to your item's root element (LinearLayout).
In addition:
Instead of changing LayoutParams manually, I suggest you to use viewType and create different layouts for position 0 and position > 0. This way, you ensure only position 0 item is bigger and you don't modify it's natural functioning.
You would add this method:
private static final int TYPE_BIG = 0;
private static final int TYPE_STANDARD = 1;
#Override
public int getItemViewType(int position) {
return position == 0 ? TYPE_BIG : TYPE_STANDARD;
}
And modify your onCreateViewHolder:
#Override
public RecyclerView.ViewHolder onCreateViewHolder(ViewGroup parent, int viewType) {
int layout = viewType == TYPE_BIG
? R.layout.item_recycler_big
: R.layout.item_recycler;
View v = View.inflate(parent.getContext(), layout, parent);
return new ViewHolder(v);
}
And your onBindViewHolder would be as simple as:
#Override
public void onBindViewHolder(final ViewHolder holder, final int position) {
WeatherForDay weather = mWeathersList.get(position);
holder.mDayTextView.setText(weather.getDay());
holder.mIconImageView.setImageResource(R.drawable.testicon1);
holder.mTempTextView.setText(weather.getTmp());
}
Hope this helps you!
Don't use position that provided from onBindViewHolder(final ViewHolder holder, final int position), it's not permanent (that's why your N-element also "large"). Use holder.getAdapterPosition() instead
Did you try to use some Gravity? For example:
a) Define android:gravity="center_vertical" for RecyclerView item layout
b) Define android:layout_gravity="center_vertical" for mRoundLayout
c) Define android:layout_centerInParent or
android:layout_centerVertical ="true"
Related
I'm trying to set the height of a ViewHolder in onBindViewHolder after changing its content but it only works at the beginning. When it gets recycled, the heights are wrong. I guess it keeps the height of the previous content. Why does it not adjust it again? What am I doing wrong?
My code (simplified):
#Override
public void onBindViewHolder(final ViewHolder holder, int position) {
holder.mItem = mValues.get(position);
holder.mMyView.setText(holder.mItem.getValue());
holder.mView.measure(
View.MeasureSpec.makeMeasureSpec(Resources.getSystem().getDisplayMetrics().widthPixels, View.MeasureSpec.EXACTLY),
View.MeasureSpec.makeMeasureSpec(0, View.MeasureSpec.UNSPECIFIED)
);
int layoutHeight = holder.mView.getMeasuredHeight();
holder.mMyView.getLayoutParams().height = layoutHeight;
//holder.mView.requestLayout();
}
public class ViewHolder extends RecyclerView.ViewHolder {
final View mView;
final TextView mMyView;
ViewHolder(View view) {
super(view);
mView = view;
mMyView= view.findViewById(R.id.myView);
}
}
Edit: My original code is a bit more complicated than this. I need to adjust the size of a view to match the size of another view. The code above is simplified to make it easier to read.
Edit 2: As requested, here is a simplified version of my XML to understand why I want to adjust the height. My goal is to adjust the ImageView height to match the height of the TextViews.
<androidx.cardview.widget.CardView
android:layout_width="match_parent"
android:layout_height="wrap_content">
<androidx.constraintlayout.widget.ConstraintLayout
android:layout_width="match_parent"
android:layout_height="wrap_content">
<TextView
android:layout_width="0dp"
android:layout_height="wrap_content"
app:layout_constraintTop_toTopOf="parent"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toStartOf="#id/imageView"
app:layout_constraintStart_toStartOf="parent"
/>
<ImageView
android:id="#+id/imageView"
android:layout_width="0dp"
android:layout_height="0dp"
app:layout_constraintTop_toTopOf="parent"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintEnd_toEndOf="parent" />
<TextView
android:layout_width="0dp"
android:layout_height="wrap_content"
app:layout_constraintTop_toTopOf="parent"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toEndOf="#imageView" />
</androidx.constraintlayout.widget.ConstraintLayout>
</androidx.cardview.widget.CardView>
Edit 3: I just set the height to a fixed value now. Calculating the height had a big impact on the performance anyway. Ridiculous how difficult it is to make layouts responsive in Android.
Thanks in advance.
Simply set height of the TextView to wrap_content in its XML file. Then change the onBindViewHolder as following:
public void onBindViewHolder(final ViewHolder holder, int position) {
holder.mItem = mValues.get(position);
holder.mMyView.setText(holder.mItem.getValue());
}
Height of the TextView will be change accordingly to its content.
#Override
public void onBindViewHolder(final ViewHolder holder, int position) {
//this is called when you scroll items
//this will reset to origin xml default items
//here heightChanged is the status , set true if changed
if(heightChanged){
//height according to logic
}else{
//do nothing
}
}
It seems like the height of items are different from each other, try adding status for height that has been changed (write logs to find out the height of each view you will get an idea how to solve this)
you have to set the height of Viewholder dynamically.just use,
public class ViewHolder extends RecyclerView.ViewHolder {
final View mView;
final TextView mMyView;
ViewHolder(View view) {
super(view);
mView = view;
mMyView= view.findViewById(R.id.myView);
view.setMinimumHeight(600); // 600 you can type you height that you want...
}
}
I am trying to make a RecyclerView with CardView elements , each item having a different color. I am using an Adapter and passing in the resource for the color.
The problem is that my elements, instead of having the color I passed in(ex: red, blue, or green), they have different shades of purple.
If I use the same code for the child Relative Layout, the colors work perfectly, but they don't fill the whole card.
This is the element of the list:
<android.support.v7.widget.CardView
android:id="#+id/rl_main_list_background_color"
xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="wrap_content"
xmlns:app="http://schemas.android.com/apk/res-auto"
app:cardCornerRadius="16dp"
android:layout_marginBottom="8dp">
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="match_parent">
<TextView
android:id="#+id/tv_main_list_game_name"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Game"
android:layout_margin="16dp"
android:textStyle="bold|italic"
android:textSize="20sp"/>
</RelativeLayout>
</android.support.v7.widget.CardView>
This is the adapter
public class GamesListAdapter extends RecyclerView.Adapter<GamesListAdapter.GamesViewHolder> {
private ArrayList<GameItem> mGamesList;
public static class GamesViewHolder extends RecyclerView.ViewHolder{
public TextView mGameName;
public CardView mItemRelativeLayour;
public GamesViewHolder(#NonNull View itemView) {
super(itemView);
mGameName = itemView.findViewById(R.id.tv_main_list_game_name);
mItemRelativeLayour = itemView.findViewById(R.id.rl_main_list_background_color);
}
}
public GamesListAdapter(ArrayList<GameItem> gamesList){ mGamesList = gamesList;}
#NonNull
#Override
public GamesViewHolder onCreateViewHolder(#NonNull ViewGroup viewGroup, int i) {
View view = LayoutInflater.from(viewGroup.getContext()).inflate(R.layout.main_list_list_element, viewGroup, false);
GamesViewHolder gamesViewHolder = new GamesViewHolder(view);
return gamesViewHolder;
}
#Override
public void onBindViewHolder(#NonNull GamesViewHolder gamesViewHolder, int i) {
GameItem currentItem = mGamesList.get(i);
gamesViewHolder.mGameName.setText(currentItem.getGameName());
gamesViewHolder.mItemRelativeLayour.setCardBackgroundColor(currentItem.getBackgroundColor());
}
#Override
public int getItemCount() {
return mGamesList.size();
}
}
And this is how I populate the list
gamesList = new ArrayList<>();
gamesList.add(new GameItem("Truth or Dare", R.color.truthOrDareColor));
gamesList.add(new GameItem("Kings", R.color.kingsColor));
gamesList.add(new GameItem("Flip the card(Urmatoarea Carte)", R.color.flipTheCardColor));
gamesList.add(new GameItem("Most likely to", R.color.mostLikelyToColor));
gamesList.add(new GameItem("Spin the bottle", R.color.spinTheBottleColor));
gamesList.add(new GameItem("I have sex like", R.color.iHaveSexLikeColor));
gamesList.add(new GameItem("Never have I ever", R.color.neverHaveIEverColor));
Any idea on how to fix this? Thanks!
Change,
gamesViewHolder.mItemRelativeLayour.setCardBackgroundColor(currentItem.getBackgroundColor());
To,
gamesViewHolder.mItemRelativeLayour.setCardBackgroundColor(
ContextCompat.getColor(context, currentItem.getBackgroundColor()));
You are setting Interger ID as Color R.color.some_color just stores reference to your color you have to get actual color from that id.
To get Color from Reference ID you should use following,
ContextCompat.getColor(context, R.color.some_color);
Happy Coding.
I have an Activity that contains a Fragment. Fragment contains a RecyclerView, displaying CardViews.
CardView is very simple, just a TextView and a CustomView. This is the layout:
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="horizontal"
android:layout_width="match_parent"
android:layout_height="100dp">
<android.support.v7.widget.CardView
android:layout_width="match_parent"
android:layout_height="100dp"
android:id="#+id/card_current_heat_cardview"
android:layout_gravity="center_vertical">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="horizontal"
android:layout_marginLeft="10dp"
android:layout_marginRight="10dp"
android:layout_marginTop="5dp"
android:layout_marginBottom="5dp"
android:weightSum="4">
<TextView
android:id="#+id/card_current_heat_textview"
android:layout_width="0dp"
android:layout_height="match_parent"
android:layout_weight="1"
android:textStyle="bold"
android:textColor="#000000"
android:background="#android:color/holo_red_dark"
android:gravity="center_vertical"/>
<com.amige.vm2.CurrentHeatChartView
android:id="#+id/card_current_heat_chart_view"
android:layout_width="0dp"
android:layout_height="match_parent"
android:layout_weight="3"/>
</LinearLayout>
</android.support.v7.widget.CardView>
</LinearLayout>
TextView should use 1/4 of the width, and the CustomView 3/4.
Im having trouble understanding why weights are ignored the first time the RecyclerView loads
Image of RecyclerView loaded for the first time
But if I scroll up and down, the layout works as expected for some Cards
Image of RecyclerView scrolled up and down
I also have another Activity (no fragment involved here) that has a RecyclerView and IS using this same CardView Layout and it works perfectly!!
I dont know if it has to do with the Fragment...
What am I missing?
Thanks!
EDIT
This the Adapter code
public class MainAdapter extends RecyclerView.Adapter<MyFragment.MainAdapter.ViewHolder>
{
public MainAdapter()
{
}
#Override
public MyFragment.MainAdapter.ViewHolder onCreateViewHolder(ViewGroup parent, int viewType)
{
View v = LayoutInflater.from(parent.getContext()).inflate(R.layout.card_current_heat, parent, false);
return new MyFragment.MainAdapter.ViewHolder(v);
}
#Override
public void onBindViewHolder(MyFragment.MainAdapter.ViewHolder holder, int position)
{
if (arrayList.size() == 2)
{
if (position == 0)
{
holder.variableNameTextView.setText(“Var Name”);
holder.currentHeatChartView.reloadChartWithSamples(arrayList.get(0));
}
else
{
if ((position - 1) < arrayList.get(1).size())
{
HashMap variableHashMap = (HashMap) arrayList.get(1).get(position - 1);
holder.variableNameTextView.setText(variableHashMap.get("VarName") != null ? (String)variableHashMap.get("VarName") : "");
holder.currentHeatChartView.reloadChartWithVariableValuesAndColors(variableHashMap, colorGradientsArrayList.get((position - 1) % colorGradientsArrayList.size()));
}
}
}
}
#Override
public int getItemCount()
{
if (arrayList.size() == 2)
{
if (arrayList.get(1).size() > 0)
{
return 1 + arrayList.get(1).size();
}
else
{
return 1;
}
}
return 0;
}
public class ViewHolder extends RecyclerView.ViewHolder
{
TextView variableNameTextView;
CurrentHeatChartView currentHeatChartView;
public ViewHolder(View v)
{
super(v);
this.variableNameTextView = (TextView) v.findViewById(R.id.card_current_heat_textview);
this.currentHeatChartView = (CurrentHeatChartView) v.findViewById(R.id.card_current_heat_chart_view);
}
}
}
I found the culprit.
There was a ConstraintLayout on top of the hierarchy of the Activity containing the Fragment. Since I was working with nested layouts, ConstraintLayout was not the right way to go.
I changed it to RelativeLayout and the cards are now rendered properly.
I think your layout inflation is wrong.
View view = View.inflate(mContext, R.layout.your_layout, null);
If you do like that change your code like this.
View view = LayoutInflater.from(mContext).(R.layout.your_layout, parent, false);
Hope it helps:)
I have a StaggeredGrid in a RecyclerView and I am trying to dynamically set the image height in the onBindViewHolder. I thought the StaggeredGrid was supposed to handle all this automatically, so I set android:layout_width="match_parent and android:scaleType="fitStart on the ImageView, but there is lots of gaps around the image.
Since the StaggeredGrid isn't living up to it, I'm trying to help it a bit by defining the image height dynamically in the onBindViewHolder. I have the width and height of the image ahead of time, but the cell width of the grid isn't available. I tried holder.cardView.getLayoutParams().width and getMeasuredWidth(), but they both return zero or small numbers. I know there are other places the cell width would be available, but I really need it in the onBindViewHolder event so I can set and adjust the image.
Any ideas on how to achieve this by leveraging the StaggeredGrid? Any advice or experience is appreciated!
In my activity is this:
mLayoutManager = new StaggeredGridLayoutManager(2, StaggeredGridLayoutManager.VERTICAL);
mRecyclerView.setLayoutManager(mLayoutManager);
In my adapter:
#Override
public void onBindViewHolder(MyAdapter.MyViewHolder holder, int position) {
MyModel item = mData.get(position);
int imageWidth = item.getFeatured_image().getWidth();
int imageHeight = item.getFeatured_image().getHeight();
int cellWidth = 540; // <==== how to find dynamically??!!
ViewGroup.LayoutParams imageLayoutParams = holder.thumbnailImageView.getLayoutParams();
imageLayoutParams.width = cellWidth;
imageLayoutParams.height = imageHeight * cellWidth / imageWidth;
holder.thumbnailImageView.setLayoutParams(imageLayoutParams);
MediaHelper.displayImage(item, holder.thumbnailImageView);
}
In my layout:
<android.support.v7.widget.CardView
xmlns:card_view="http://schemas.android.com/apk/res-auto"
android:id="#+id/row_my_card"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_margin="5dp"
card_view:cardCornerRadius="2dp">
<ImageView
android:id="#+id/row_my_thumbnail_image"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_gravity="top"
android:scaleType="fitStart" />
<TextView
android:id="#+id/row_my_title_text"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_gravity="bottom"
android:background="#CCFFFFFF"
android:textStyle="bold"
android:padding="5dp" />
</android.support.v7.widget.CardView>
I also tried to add this which does give me the cell width, but the onGlobalLayout event gets triggered way after the image is set and adjusted in the onBindViewHolder event so it's too late.
#Override
public MyAdapter.MyViewHolder onCreateViewHolder(ViewGroup parent, int viewType) {
// create a new view
final View view = LayoutInflater.from(parent.getContext())
.inflate(R.layout.row_my_post, parent, false);
final MyViewHolder viewHolder = new MyViewHolder(view);
ViewTreeObserver viewTreeObserver = view.getViewTreeObserver();
if (viewTreeObserver.isAlive()) {
viewTreeObserver.addOnGlobalLayoutListener(new ViewTreeObserver.OnGlobalLayoutListener() {
#Override
public void onGlobalLayout() {
view.getViewTreeObserver().removeOnGlobalLayoutListener(this);
int viewWidth = view.getWidth();
int viewHeight = view.getHeight();
}
});
}
return viewHolder;
}
Here is the gaps which are random due to the various image sizes. What I would like is for ALL images to be the width of the cell and let the height of the image and cell adjust dynamically:
Try This:- add this in your ImageView--> android:adjustViewBounds="true"
<android.support.v7.widget.CardView
xmlns:card_view="http://schemas.android.com/apk/res-auto"
android:id="#+id/row_my_card"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_margin="5dp"
card_view:cardCornerRadius="2dp">
<ImageView
android:id="#+id/row_my_thumbnail_image"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_gravity="top"
android:adjustViewBounds="true"/>
<TextView
android:id="#+id/row_my_title_text"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_gravity="bottom"
android:background="#CCFFFFFF"
android:textStyle="bold"
android:padding="5dp" />
</android.support.v7.widget.CardView>
Instead of getting the view height and width from onCreateViewHolder get it from onBindViewHolder as below:
#Override
public void onBindViewHolder(final MyAdapter.MyViewHolder holder, int position)
{
holder.itemView.post(new Runnable()
{
#Override
public void run()
{
MyModel item = mData.get(position);
int imageWidth = item.getFeatured_image().getWidth();
int imageHeight = item.getFeatured_image().getHeight();
int cellWidth = 540; // <==== how to find dynamically??!!
cellWidth = holder.itemView.getWidth();// this will give you width dynamically
ViewGroup.LayoutParams imageLayoutParams = holder.thumbnailImageView.getLayoutParams();
imageLayoutParams.width = cellWidth;
imageLayoutParams.height = imageHeight * cellWidth / imageWidth;
holder.thumbnailImageView.setLayoutParams(imageLayoutParams);
MediaHelper.displayImage(item, holder.thumbnailImageView);
}
});
}
I hope this will help you!!
The cell's width can be found at activity/fragment level and passed to the adapter before rendering time. Use something like this:
this.staggeredGridLayoutManager.getWidth() / this.staggeredGridLayoutManager.getSpanCount()
With this approach, you will be able to compute the cell's height before any rendering and avoid that initial flick introduced by post run approach.
Also, the image's aspect ratio will be preserved and you can reserve the required space before image load.
Be also aware that if any margins/paddings are present you should include them into previous calculation. Something like:
(this.staggeredGridLayoutManager.getWidth() - marginsAndOrPaddings) / this.staggeredGridLayoutManager.getSpanCount()
Update:
Starting with support packages 23.2.0, and at this point of lifecycle, this.staggeredGridLayoutManager.getWidth() returns 0. The total width can be achieved with this.recyclerView.getWidth()
I implemented a listview with 2 kinds of rows from here listViews with multiple rows tutorial
all is working properly,
the problem that I have now is setting the height for the rows,
if I leave the background as a color, all is good,
but if I use an image for background, I only get a tall row [on other simple list views the height respect the programatically set height], but in this case, the row changes
so
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:id="#+id/category_item_row"
android:orientation="horizontal"
android:layout_width="fill_parent"
android:background="#ff00ff"
android:layout_height="70dp"
android:padding="3dp"
>
<ImageView
android:id="#+id/image"
android:layout_width="40dp"
android:layout_height="70dp"
android:gravity="center_vertical"/>
<TextView
android:id="#+id/title"
android:textSize="20sp"
android:layout_width="90dp"
android:layout_height="70dp"
android:gravity="center_vertical"/>
</LinearLayout>
works fine,
but
android:background="#drawable/phone_cat_cell">
is not respecting the assigned height,
how to fix this height using my image background?
thanks!
edit 1, adapter
listViewItem.setAdapter(new PhoneItemAdapter(new ItemPhoneDataSource().getItems()));
private class PhoneItemAdapter extends BaseAdapter {
final List<RowPhone> rows;//row
//data source, style
PhoneItemAdapter(List<ItemPhone> animals) {
rows = new ArrayList<RowPhone>();//member variable
//choose cell! iterator
for (ItemPhone item : animals) {
//if it has an image, use an ImageRow
if (item.getImageId() != null) {
rows.add(new RowFolderPhone(LayoutInflater.from(getActivity()), item)); //imageRow!
} else {//otherwise use a DescriptionRow
rows.add(new RowItemPhone(LayoutInflater.from(getActivity()), item));
}
}
}
//delegate
#Override
public int getViewTypeCount() {
return RowTypePhone.values().length;
}
#Override
public int getItemViewType(int position) {
//con cast
return ((RowPhone) rows.get(position)).getViewType();
}
public int getCount() {
return rows.size();
}
public Object getItem(int position) {
return position;
}
public long getItemId(int position) {
return position;
}
public View getView(int position, View convertView, ViewGroup parent) {
//cambiado con cast!
return ((RowPhone) rows.get(position)).getView(convertView);
}
}
Check your adapter code, if you are passing null while inflating the view then please replace that code with this.
view = inflater.inflate(R.layout.listview_row, parent, false);
you just need to make not static images, but "9patch" images.
All android versions are supporting that.
Have a look here http://developer.android.com/tools/help/draw9patch.html
Try this:
<ImageView
android:id="#+id/image"
android:layout_width="40dp"
android:layout_height="70dp"
android:scaleType="fitXY"
android:adjustViewBounds="true"
android:gravity="center_vertical"/>