求launcher showPreviews代码一份
[img=http://image.baidu.com/i?ct=503316480&z=0&tn=baiduimagedetail&word=go+launcher&in=31696&cl=2&lm=-1&pn=23&rn=1&di=263773005&ln=2000&fr=&fmq=&ic=0&s=0&se=1&sme=0&tab=&width=&height=&face=0&is=&istype=2#pn23&-1&di263773005&objURLhttp%3A%2F%2Fwww.androidmi.com%2Fuploadfile%2F2010%2F1205%2F20101205122004629.jpg&fromURLhttp%3A%2F%2Fwww.androidmi.com%2Fxz%2Fcyrj%2Fzhuomian%2F201012%2Fgo-launcher.html&W360&H641][/img] --------------------编程问答-------------------- 跟go Launcher 屏幕预览效果差不多. --------------------编程问答-------------------- 没明白你的问题!呵呵不是一个桌面运用啊 --------------------编程问答-------------------- 呵呵 不要小看了, 用过go Launcher没? 大致跟它那种浏览screen 差不多,可以增加screen 也可以删除 --------------------编程问答-------------------- --------------------编程问答-------------------- private void showPreviews(final View anchor, int start, int end){
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);
}
补充:移动开发 , Android