解决方案 »
- 列表对话框无法显示
- 关于安卓OnClickListenter的问题 菜鸟求助
- viewpager嵌套webView滑动问题,如何判断webview滑动至最左或最右
- ScrollView
- 从一个Activity跳转到另一个Activity,发生FATAL EXCEPTION:main错误求解决!
- Android如何判断应用程序是安装在手机内存中还是SD卡中的呢?
- 在关机前触发程序
- 如何实现ActionBar标题栏(非选项)处的点击事件
- apk反编译之后如何变成安卓的项目?求大神赐教
- Android工程引入第三方jar包报错
- 100分求问,tablelayout中删除tablerow
- 如何在一个控件里画图?而不是在一个Activity里画图?
{
final Resources resources = getResources();
final lhkworkspace workspace = mWorkspace;
System.out.println("end=" +end);
CellLayout cell = ((CellLayout) workspace.getChildAt(start));
float max = workspace.getChildCount();
final Rect r = new Rect();//8*6
resources.getDrawable(R.drawable.preview_background).getPadding(r);
int extraW = (int) ((r.left + r.right) * max); //40
int extraH = r.top + r.bottom; //6
System.out.println("extraW=" +extraW);
System.out.println("extraH=" +extraH);
int aW = cell.getWidth() - extraW;
System.out.println("cell.getWidth()=" +cell.getWidth());//0
float w = aW / max; int width = cell.getWidth();
int height = cell.getHeight();
System.out.println("cell.getHeight()=" +cell.getHeight());//0
int x = cell.getLeftPadding();//6
int y = cell.getTopPadding();//0
System.out.println("x=" +x);
System.out.println("y=" +y);
width -= (x + cell.getRightPadding());
height -= (y + cell.getBottomPadding());
System.out.println("cell.getRightPadding()=" +cell.getRightPadding());//59
System.out.println("cell.getBottomPadding()=" +cell.getBottomPadding());//0
float scale = w / width; int count = end - start; final float sWidth = width * scale;
float sHeight = height * scale; LinearLayout preview = new LinearLayout(this); PreviewTouchHandler handler = new PreviewTouchHandler(anchor);
ArrayList<Bitmap> bitmaps = new ArrayList<Bitmap>(count);
System.out.println(sWidth);
System.out.println(sHeight);
for (int i = start; i < end; i++)
{
ImageView image = new ImageView(this);
cell = (CellLayout) workspace.getChildAt(i); final Bitmap bitmap = Bitmap.createBitmap((int) 30, (int) 40,
Bitmap.Config.ARGB_8888); final Canvas c = new Canvas(bitmap);
c.scale(scale, scale);
c.translate(-cell.getLeftPadding(), -cell.getTopPadding());
cell.dispatchDraw(c); image.setBackgroundDrawable(resources.getDrawable(R.drawable.preview_background));
image.setImageBitmap(bitmap);
image.setTag(i);
image.setOnClickListener(handler);
image.setOnFocusChangeListener(handler);
image.setFocusable(true);
if (i == mWorkspace.getCurrentScreen()) image.requestFocus(); preview.addView(image,
LinearLayout.LayoutParams.WRAP_CONTENT, LinearLayout.LayoutParams.WRAP_CONTENT); bitmaps.add(bitmap);
} final PopupWindow p = new PopupWindow(this);
p.setContentView(preview);
p.setWidth((int) (200));
p.setHeight((int) (40));
p.setAnimationStyle(R.style.AnimationPreview);
p.setOutsideTouchable(true);
p.setFocusable(true);
p.setBackgroundDrawable(new ColorDrawable(0));
p.showAsDropDown(anchor, 0, 0); p.setOnDismissListener(new PopupWindow.OnDismissListener()
{
public void onDismiss()
{
dismissPreview(anchor);
}
}); anchor.setTag(p);
anchor.setTag(R.id.workspace, preview);
anchor.setTag(R.id.icon, bitmaps);
}