自定义列表查看图像点击android

时间:2015-06-10 09:50:09

标签: android

我创建一个自定义列表视图。我想点击Imageview时缩放图像。它类似于什么应用程序。当我点击任何人的DP时,它缩放。类似我想要的项目。它是如何工作的。

enter image description here

I want just like this 在此先感谢朋友们。!

2 个答案:

答案 0 :(得分:1)

我建议你使用Android Dev网站上的“缩放视图”示例

http://developer.android.com/training/animation/zoom.html

这很简单,效果很好!

答案 1 :(得分:0)

有很多方法可以做到这一点。

我可以在这里用PopupWindow

解释

第1步:

your_main_imageview.setOnClickListener(new OnClickListener() {

                    @Override
                    public void onClick(final View anchorView) {
View popupView = getLayoutInflater().inflate(
                                    R.layout.popup_layout, null);
//Note: Add an imageView in this popup_layout.
ImageView image_button = (ImageView) popupView
                                    .findViewById(R.id.your_imageview);
//Set image for imageView here
PopupWindow popupWindow = new PopupWindow(popupView,
                                    LayoutParams.MATCH_PARENT,
                                    LayoutParams.MATCH_PARENT);
// If the PopupWindow should be focusable
                            popupWindow.setFocusable(false);
                            popupWindow.setOutsideTouchable(false);
                            // If you need the PopupWindow to dismiss when when
                            // touched outside
                            popupWindow
                                    .setBackgroundDrawable(new ColorDrawable());

                            final int location[] = new int[2];

                            // Get the View's(the one that was clicked in the
                            // Fragment) location
                            anchorView.getLocationOnScreen(location);
anchorView.post(new Runnable() {

                                @Override
                                public void run() {
                                    // Using location, the PopupWindow will be
                                    // displayed right under anchorView
                                    popupWindow.showAtLocation(
                                            anchorView,
                                            Gravity.NO_GRAVITY,
                                            location[0],
                                            location[1]
                                                    + anchorView.getHeight());
                                }
                            });


}

这不是完整的代码。如有任何疑问,我会在评论中解释