Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8007637
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 4, 20262026-06-04T17:53:47+00:00 2026-06-04T17:53:47+00:00

I have listview similar to this: Add code, it isn’t much, but maybe helpful:

  • 0

I have listview similar to this:enter image description here

Add code, it isn’t much, but maybe helpful:

CustomAdapter:

public class MyAdapter extends BaseAdapter{

private LayoutInflater mInflater;
private Animation fadeIn;
private Animation fadeOut;



public MyAdapter(Activity c) {
    mInflater = c.getLayoutInflater();
    fadeIn = AnimationUtils.loadAnimation(c.getApplicationContext(), R.anim.alpha_show);
    fadeIn.setFillAfter(true);
    fadeOut = AnimationUtils.loadAnimation(c.getApplicationContext(), R.anim.alpha_dissappear);
    fadeOut.setFillAfter(true);
}

public int getCount() {
    return MainButtonsList.getList().getSize() + 
            GlobalPrefs.getEmptyRowsAtEnd() + 
            GlobalPrefs.getEmptyRowsAtStart();
}


public View getView(int position, View v, ViewGroup parent) {
    View convertView = v;
    if (convertView == null) {
        convertView = mInflater.inflate(R.layout.main_list_item, null);
    }
    ImageView iv = (ImageView) convertView.findViewById(R.id.image);
    if ((position > GlobalPrefs.getEmptyRowsAtStart() - 1) && (position < getCount() - GlobalPrefs.getEmptyRowsAtEnd())) {
        iv.setImageResource(MainButtonsList.getList().getListImageResource(position - GlobalPrefs.getEmptyRowsAtStart()));
        iv.setAlpha(255);
        iv.setTag(MainButtonsList.UNPRESSED_BUTTON_TAG);
    } else {
        iv.setTag(MainButtonsList.UNUSED_BUTTON_TAG);
        iv.setAlpha(0);
        iv.setVisibility(0);
        iv.setClickable(false);
        iv.setImageResource(R.drawable.logo_list_null);

    }
    iv.setMaxHeight(GlobalPrefs.getRowHeight());
    iv.setMaxWidth(GlobalPrefs.getRowWidth());
    iv.setBackgroundResource(0);





    return convertView;
}

public Object getItem(int position) {
    return MainButtonsList.getList().getObject(position);
}

public long getItemId(int position) {
    return position;
}

}

Custom ListView:

public class CopyOfListView3d extends ListView{
private final Camera mCamera = new Camera();
private final Matrix mMatrix = new Matrix();
private Context context;
private Paint mPaint;


public CopyOfListView3d(Context context, AttributeSet attrs) {
    super(context, attrs);
    this.context = context;
    this.setChildrenDrawingOrderEnabled(true);

}

@Override
protected int getChildDrawingOrder (int childCount, int i) {
      //sets order number to each child, so makes overlap and center is always on top
    }

@Override
protected boolean drawChild(Canvas canvas, View child, long drawingTime) {
    // get top left coordinates
    boolean isCenter = false;
    final int top = child.getTop();
    final int bottom = child.getBottom();
    Bitmap bitmap = child.getDrawingCache();
    if (bitmap == null) {
        child.setDrawingCacheEnabled(true);
        child.buildDrawingCache();
        bitmap = child.getDrawingCache();
    }

    final int centerY = child.getHeight() / 2;
    final int centerX = child.getWidth() / 2;
    final int radius = getHeight() / 2;
    final int absParentCenterY = getTop() + getHeight() / 2;
    final int absChildCenterY = child.getTop() + centerY;
    final int distanceY = (absParentCenterY - absChildCenterY) / 2;
    final int absDistance = Math.min(radius, Math.abs(distanceY));

    final float translateZ = (float) Math.sqrt((radius * radius) - (absDistance * absDistance));
    mCamera.save();
    float myTranslateX = (float) (translateZ * (1.5f));

    int density = GlobalPrefs.getDensity();
    if (density < DisplayMetrics.DENSITY_LOW) {
        myTranslateX = (float) myTranslateX - 80;
    } else if (density == DisplayMetrics.DENSITY_LOW) {
        myTranslateX = (float) myTranslateX - GlobalPrefs.getScreenWidth() + density + 40;
    } else if (density <= DisplayMetrics.DENSITY_MEDIUM) {
            myTranslateX = (float) myTranslateX - ((float)(GlobalPrefs.getScreenWidth()*0.75)) + density/2;
    } else
        if (density <= DisplayMetrics.DENSITY_HIGH) {
            myTranslateX = (float) myTranslateX - 320;
        } else
            if (density > DisplayMetrics.DENSITY_HIGH) {
                //Log.i("density", "this is more than high");
                myTranslateX = (float) myTranslateX;
            }
    if ((top < absParentCenterY) && (bottom > absParentCenterY)) {
        //make center row bigger
        isCenter = true;
        mCamera.translate((float) myTranslateX, 0, (float) -160);//130
        child.setPressed(true);
        child.setTag(MainButtonsList.PRESSED_BUTTON_TAG);
    }  
    else {
        //top
        child.setTag(MainButtonsList.UNPRESSED_BUTTON_TAG);
        child.setPressed(false);
        mCamera.translate((float) myTranslateX, 0, -150);//120;
    };
    mCamera.getMatrix(mMatrix);
    mCamera.restore();

    // create and initialize the paint object
    if (mPaint == null) {
        mPaint = new Paint();
        mPaint.setAntiAlias(true);
        mPaint.setFilterBitmap(true);
    }
    //calculates alpha for each row, so far from center, rows are barely visible
    mPaint.setAlpha(calculateAlpha(absChildCenterY));

    mMatrix.postTranslate((float) (-centerX * 1.5f), top);
    canvas.drawBitmap(bitmap, mMatrix, mPaint);
    return false;
}



}

They are made of ImageViews where white color is selected state and blue color is unselected state and I change selected/unselected by screen coordinates, so center always is selected.

I have custom 3dListView which extends ListView and made custom adapter, where i set imageviews to rows. Code is too much to show, but there are pretty simple

One of these could be helpfull:

1) How can I make fade in (maybe also fade out) for center row (I can find which row is center when giving parent or childCount)? (Better)

2) It also could be helpfull if there is any OnStateChange listener, which listens to view’s presses. Then I could fade in anytime when view becomes pressed and fadeout, when looses press.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-04T17:53:49+00:00Added an answer on June 4, 2026 at 5:53 pm

    I found an answer myself. Added this code piece to my custom ListView in drawChild method end:

    final ImageView iv = (ImageView) child.findViewById(R.id.image);
                child.setTag(MainButtonsList.PRESSED_BUTTON_TAG);
    
                Animation anim = fadeOut();
                anim.setAnimationListener(new Animation.AnimationListener() {
    
                    public void onAnimationStart(Animation animation) {
                        // TODO Auto-generated method stub
    
                    }
    
                    public void onAnimationRepeat(Animation animation) {
                        // TODO Auto-generated method stub
    
                    }
    
                    public void onAnimationEnd(Animation animation) {
                        child.setPressed(true);
                        iv.startAnimation(fadeIn());
                    }
                });
    
                iv.clearAnimation();
                iv.startAnimation(anim);
    

    In list item layout, added another image, which put under item and now it looks prety nice.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a listview, where I set the datasource in the code-behind - this
I have a wx.ListView box named lvActions that I add data to using code
I have a ListView similar to this: Name | Pass | Proxy | Keyword
I would like to have a ListView that would have have items similar to
I found a similar question about scrolling listview and button click but it did
Similar to my other question : I have a ListView bound to a Dictionary.
I have this Code of Showing all Records to a Message box using string
I have a problem similar to the one found in this Question I have
So this is pretty mystifying. I have a databound ListBox (or ListView , it
I have a problem similar to this question: Wicket: can Checkgroup be Ajax enabled?

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.