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

  & 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;   

Java code

  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;}   

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.

Comments

Popular posts from this blog

Verilog Error: output or inout port "Q" must be connected to a structural net expression -

jasper reports - How to center align barcode using jasperreports and barcode4j -

c# - ASP.NET MVC - Attaching an entity of type 'MODELNAME' failed because another entity of the same type already has the same primary key value -