Android完成后拖放捕获屏幕

时间:2012-02-15 06:59:43

标签: android drag-and-drop screenshot

我正在做一个Android应用程序,用户可以在屏幕上拖放按钮然后从手动设置中捕获该图像并将其发送给我。我得到了拖放,我上传了图片,现在我只需要在不使用DDM的情况下从设备上接收重新定位按钮的屏幕抓取。这是我的MainActivity

public class DragSymbols extends Activity {


            // Define the symbols and their initial coordinates in arrays. No limit in principle 
            // to how many. Coordinates are measured from the upper left corner of the screen, 
            // with x increasing to the right and y increasing downward



            float [] X = {2, 2, 2, 2, 2, };   // Initial x coord in pixels of upper left corner of symbol
            float [] Y = {2, 2, 2, 2, 2, };     // Initial y coord in pixels of upper left corner of symbol

            // The Drawable corresponding to the symbol. R.drawable.file refers to file.png, .jpg, 
            // or .gif stored in res/drawable-hdpi (referenced from code without the extension).


            // 5 Buttons in Total
            int[]symbolIndex = {R.drawable.twit,R.drawable.twit, R.drawable.twit,R.drawable.twit,R.drawable.twit,};

            // Instantiate a SymbolDragger instance (which subclasses View), passing to it in the
            // constructor the context (this) and the above arrays.  Then set the content view to 
            // this instance of SymbolDragger (so the layout is being specified entirely by SymbolDragger, 
            // with no XML layout file).  The resulting view should then place draggable symbols with 
            // content and initial position defined by the above arrays on the screen.

            SymbolDragger view = new SymbolDragger(this, X, Y, symbolIndex);
            view.setLayoutParams(new ViewGroup.LayoutParams(ViewGroup.LayoutParams.FILL_PARENT,
                ViewGroup.LayoutParams.FILL_PARENT));
            setContentView(view);
        }
    }

1 个答案:

答案 0 :(得分:1)

根据我的理解,您希望在拖放完成后获取应用程序的屏幕截图。为此你可以去下面的链接,这可以重定向你正确的方向

http://coderzheaven.com/2011/10/how-to-take-screenshot-of-your-phone-in-android-through-code/

http://coderzheaven.com/2011/10/how-to-create-screenshot-of-application-and-store-it-in-sdcard/

希望这有帮助。