S selvamurali Active Member Licensed User Longtime User Oct 2, 2012 #1 dear team i used the following code to draw line on panel background image Sub Activity_Touch (Action As Int, X As Float, Y As Float) pnlTest.Color=Colors.Transparent cvsTest.Initialize(pnlTest) cvsTest.DrawLine(x1,y1-pnlTest.Top,x2,y2-pnlTest.Top,Colors.Red,LineWidth) pnlTest.Invalidate End sub in the above code if i use colors.transparent line drawed correctly. but image hide. so if i remove that line line image showed and line drawed multiple or bended line . what wrong with my code help me. thanks in advance sorry for my english
dear team i used the following code to draw line on panel background image Sub Activity_Touch (Action As Int, X As Float, Y As Float) pnlTest.Color=Colors.Transparent cvsTest.Initialize(pnlTest) cvsTest.DrawLine(x1,y1-pnlTest.Top,x2,y2-pnlTest.Top,Colors.Red,LineWidth) pnlTest.Invalidate End sub in the above code if i use colors.transparent line drawed correctly. but image hide. so if i remove that line line image showed and line drawed multiple or bended line . what wrong with my code help me. thanks in advance sorry for my english
klaus Expert Licensed User Longtime User Oct 2, 2012 #2 Attached you have a small test program. With the Draw button a line and a circle are drawn onto the image. With the Erase button the original image is reloaded 'erasing' the drawing. Touching the screen you can draw 'rubber banding' lines. For this a second transparent Panel is added, the rubber banding lines are drawn onto this panel and the final line is drawn onto the image when Action is ACTION_UP. Best regards. Attachments DrawPanel.zip DrawPanel.zip 34.6 KB · Views: 1,615 Upvote 0
Attached you have a small test program. With the Draw button a line and a circle are drawn onto the image. With the Erase button the original image is reloaded 'erasing' the drawing. Touching the screen you can draw 'rubber banding' lines. For this a second transparent Panel is added, the rubber banding lines are drawn onto this panel and the final line is drawn onto the image when Action is ACTION_UP. Best regards.
S selvamurali Active Member Licensed User Longtime User Oct 3, 2012 #3 Very nice example Thanks Klaus That was an nice example. and also i want to erase selected part of line in the canvas . is it possible? It really very helpfull for my project . Upvote 0
Very nice example Thanks Klaus That was an nice example. and also i want to erase selected part of line in the canvas . is it possible? It really very helpfull for my project .
klaus Expert Licensed User Longtime User Oct 3, 2012 #4 and also i want to erase selected part of line in the canvas . is it possible? Click to expand... No, because on the bitmap the original pixel colors are replaced by the new color. What you could do is to save the last bitmaps and call those back. But this could become a memory problem. I had used this in a Basic4PPC Icon editor program, I memorized the last three screens. Best regards. Upvote 0
and also i want to erase selected part of line in the canvas . is it possible? Click to expand... No, because on the bitmap the original pixel colors are replaced by the new color. What you could do is to save the last bitmaps and call those back. But this could become a memory problem. I had used this in a Basic4PPC Icon editor program, I memorized the last three screens. Best regards.
Xardoz Member Licensed User Longtime User Apr 19, 2014 #5 Can you draw straight onto a panel? Upvote 0
klaus Expert Licensed User Longtime User Apr 19, 2014 #6 Sorry, I don't understand, what exactly you mean ? Upvote 0
Xardoz Member Licensed User Longtime User Apr 19, 2014 #7 I have a panel with buttons on it I want a horizontal line between the rows as a visual seperator Not sure if it matters, I am using the AHViewPageFixer control Upvote 0
I have a panel with buttons on it I want a horizontal line between the rows as a visual seperator Not sure if it matters, I am using the AHViewPageFixer control
klaus Expert Licensed User Longtime User Apr 19, 2014 #8 You can either : - Add a small Panel with the given color. - Draw a line onto the Panel background. I have never used AHViewPageFixer. Upvote 0
You can either : - Add a small Panel with the given color. - Draw a line onto the Panel background. I have never used AHViewPageFixer.
Xardoz Member Licensed User Longtime User Apr 20, 2014 #9 Not sure how to do this, sorry to sound dense... Code: Copy Dim pan As Panel pan = CreatePanel("Times" ) container.AddPage(pan, "Times") cvsBackground.Initialize(pan.Background) cvsBackground.DrawLine(10dip, 50dip, 150dip, 100dip, Colors.Black, 5dip) Upvote 0
Not sure how to do this, sorry to sound dense... Code: Copy Dim pan As Panel pan = CreatePanel("Times" ) container.AddPage(pan, "Times") cvsBackground.Initialize(pan.Background) cvsBackground.DrawLine(10dip, 50dip, 150dip, 100dip, Colors.Black, 5dip)
klaus Expert Licensed User Longtime User Apr 20, 2014 #10 You don't post enough code. What does CreatePanel do ? Try cvsBackground.Initialize(pan) pan.Background is a Drawable and not a Bitmap. Upvote 0
You don't post enough code. What does CreatePanel do ? Try cvsBackground.Initialize(pan) pan.Background is a Drawable and not a Bitmap.
Xardoz Member Licensed User Longtime User Apr 20, 2014 #11 Thank you for the help It is based on the example for the AHViewPagerFixer Demo When I try your suggestion I get: LogCat connected to: 0146DE220400D00A --------- beginning of /dev/log/system --------- beginning of /dev/log/main ** Activity (main) Create, isFirst = true ** Error occurred on line: 79 (main) java.lang.NullPointerException at anywheresoftware.b4a.objects.drawable.CanvasWrapper.Initialize(CanvasWrapper.java:76) at de.amberhome.viewpagerexample.main._activity_create(main.java:346) at java.lang.reflect.Method.invokeNative(Native Method) at java.lang.reflect.Method.invoke(Method.java:511) at anywheresoftware.b4a.shell.Shell.runMethod(Shell.java:636) at anywheresoftware.b4a.shell.Shell.raiseEventImpl(Shell.java:302) at anywheresoftware.b4a.shell.Shell.raiseEvent(Shell.java:238) at java.lang.reflect.Method.invokeNative(Native Method) at java.lang.reflect.Method.invoke(Method.java:511) at anywheresoftware.b4a.ShellBA.raiseEvent2(ShellBA.java:121) at de.amberhome.viewpagerexample.main.afterFirstLayout(main.java:98) at de.amberhome.viewpagerexample.main.access$100(main.java:16) at de.amberhome.viewpagerexample.main$WaitForLayout.run(main.java:76) at android.os.Handler.handleCallback(Handler.java:615) at android.os.Handler.dispatchMessage(Handler.java:92) at android.os.Looper.loop(Looper.java:137) at android.app.ActivityThread.main(ActivityThread.java:5059) at java.lang.reflect.Method.invokeNative(Native Method) at java.lang.reflect.Method.invoke(Method.java:511) at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:792) at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:555) at dalvik.system.NativeStart.main(Native Method) ** Activity (main) Resume ** Click to expand... Last edited: Apr 20, 2014 Upvote 0
Thank you for the help It is based on the example for the AHViewPagerFixer Demo When I try your suggestion I get: LogCat connected to: 0146DE220400D00A --------- beginning of /dev/log/system --------- beginning of /dev/log/main ** Activity (main) Create, isFirst = true ** Error occurred on line: 79 (main) java.lang.NullPointerException at anywheresoftware.b4a.objects.drawable.CanvasWrapper.Initialize(CanvasWrapper.java:76) at de.amberhome.viewpagerexample.main._activity_create(main.java:346) at java.lang.reflect.Method.invokeNative(Native Method) at java.lang.reflect.Method.invoke(Method.java:511) at anywheresoftware.b4a.shell.Shell.runMethod(Shell.java:636) at anywheresoftware.b4a.shell.Shell.raiseEventImpl(Shell.java:302) at anywheresoftware.b4a.shell.Shell.raiseEvent(Shell.java:238) at java.lang.reflect.Method.invokeNative(Native Method) at java.lang.reflect.Method.invoke(Method.java:511) at anywheresoftware.b4a.ShellBA.raiseEvent2(ShellBA.java:121) at de.amberhome.viewpagerexample.main.afterFirstLayout(main.java:98) at de.amberhome.viewpagerexample.main.access$100(main.java:16) at de.amberhome.viewpagerexample.main$WaitForLayout.run(main.java:76) at android.os.Handler.handleCallback(Handler.java:615) at android.os.Handler.dispatchMessage(Handler.java:92) at android.os.Looper.loop(Looper.java:137) at android.app.ActivityThread.main(ActivityThread.java:5059) at java.lang.reflect.Method.invokeNative(Native Method) at java.lang.reflect.Method.invoke(Method.java:511) at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:792) at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:555) at dalvik.system.NativeStart.main(Native Method) ** Activity (main) Resume ** Click to expand...
klaus Expert Licensed User Longtime User Apr 20, 2014 #12 It would be easier to help if you posted your test project as a zip file. Upvote 0
Xardoz Member Licensed User Longtime User Apr 20, 2014 #13 Here you go.... http://xardoz.com/AHViewPager.zip Upvote 0
klaus Expert Licensed User Longtime User Apr 20, 2014 #14 Instead of : Code: Copy cvsBackground.Initialize(pan) cvsBackground.DrawLine(10dip, 50dip, 150dip, 100dip, Colors.Black, 5dip) Use this, you need to adapt the values to your needs : Code: Copy Dim pnl As Panel pnl.Initialize("") pnl.Color = Colors.Black pan.AddView(pnl, 10dip, 42dip, 175dip, 3dip) In your case the panel background is a ColorDrawable and not a BitmapDrawable. You must use dip values for the positions and dimensions of Views !!! Upvote 0
Instead of : Code: Copy cvsBackground.Initialize(pan) cvsBackground.DrawLine(10dip, 50dip, 150dip, 100dip, Colors.Black, 5dip) Use this, you need to adapt the values to your needs : Code: Copy Dim pnl As Panel pnl.Initialize("") pnl.Color = Colors.Black pan.AddView(pnl, 10dip, 42dip, 175dip, 3dip) In your case the panel background is a ColorDrawable and not a BitmapDrawable. You must use dip values for the positions and dimensions of Views !!!
Xardoz Member Licensed User Longtime User Apr 20, 2014 #15 THANK YOU! Got it! Make a panel to look like a line on top of the existing panel. Last edited: Apr 20, 2014 Upvote 0