How to connect an xml layout with a view ANDROID -
I have a problem, I want to add XML layout to a visual class that does painting. The main idea is that I want to come to the layout.
XML file Java code I have tried many things but have not done anything. This is showing a blank white screen. Thanks in advance! You have to create it and then include it in your XML layout definition.
& lt; FrameLayout xmlns: android = "http: /sschemas.android.com/apk/res/android" android: id = "@ + id / my_frame" Android: layout_width = "fill_parent" Android: layout_height = "fill_parent" & gt; & Lt; ImageView Android: Android: Android: layout_width = "fail_parent" android: layout_height = "fill_parent" android: scaleType = "fitcenter" Android: src = "@drawable / inverge" /> & Lt; ImageView Android: Android: Android: Android: Layout_Width = "FailPart" Android: Layout_hett = "FailPart" Android: Scalptipe = "Fitcenter" Android: src = "@Drawable / A" Android: Visibility = "Invisible" /> ; & Lt; / FrameLayout & gt;
increases the public square TouchEventView view {Private Paint Paint = New Paint (); Private Path Path = New Path (); Public TouchEventView (reference ctx, AttributeSet attrs) {super (CTX, ethers); Paint.setAntiAlias (right); paint.setColor (Color.YELLOW); paint.setStrokeJoin (Paint.Join.ROUND); Paint.setStyle (Paint.Style.STROKE); Paint.setStrokeWidth (5f);} protected void onDraw (canvas canvas) {canvas.drawpath (path, paint);} @ override public boolean on touch event (int event) {int xPos = (int) event.getX () ; int yPos = (int) event.getY (); Switch (event.getAction ()) {case MotionEvent.ACTION_DOWN: path.moveTo (xPos, yPos); Back true; Case MotionEvent.ACTION_MOVE: path.lineTo (xPos, yPos); break; Case MotionEvent.ACTION_UP: Break; Default: Return false; } Invalid (); Return true;}
Comments
Post a Comment