解决方案 »
- android怎么将一个文本文件写入pc机
- 初学Android开发,弱弱地问两个问题,老TX不要见笑...
- 请问Android出现这个问题怎么解决,先谢过了!!呵呵
- Android NDK中如何编译Box2d c++获得so文件?
- 参加谷歌android编程大赛遇到的一些困惑
- 在android中我安装了某apk,然后我把它给卸载掉。在程序中用说明可以知道该apk不在了呢?
- 怎样动态更新gridview的某个item
- 关于android手机实现虚拟SIM卡
- TextView结尾...结束的一个奇怪现象
- 6.0拍照不申请权限
- 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);
}