Spanish Dibujar gráfico de lineas

carlos7000

Well-Known Member
Licensed User
Longtime User
Hola.

Deseo hacer un gráfico de lineas.

En mi primer intento lo que obtuve fue esto:



¿Porqué en lugar de dibujar una línea, dibuja 2?

Este fue el código que empleé

B4X:
#Region  Project Attributes
    #ApplicationLabel: B4A Example
    #VersionCode: 1
    #VersionName:
    'SupportedOrientations possible values: unspecified, landscape or portrait.
    #SupportedOrientations: unspecified
    #CanInstallToExternalStorage: False
#End Region

#Region  Activity Attributes
    #FullScreen: False
    #IncludeTitle: True
#End Region

Sub Process_Globals
    'These global variables will be declared once when the application starts.
    'These variables can be accessed from all modules.

End Sub

Sub Globals
    'These global variables will be redeclared each time the activity is created.
    'These variables can only be accessed from this module.

    Private Panel1 As Panel
    Dim C As Canvas
End Sub

Sub Activity_Create(FirstTime As Boolean)
    'Do not forget to load the layout file created with the visual designer. For example:
    Activity.LoadLayout("Layout1")
    C.Initialize(Activity)
    C.DrawLine(100dip, 100dip, 200dip, 200dip, Colors.Red, 1dip)
    Activity.Invalidate
    Panel1.SetBackgroundImage(C.Bitmap)
End Sub

Sub Activity_Resume

End Sub

Sub Activity_Pause (UserClosed As Boolean)

End Sub
 
Last edited:

mlc

Active Member
Licensed User
Longtime User
Hola

Supongo que una linea es la que dibujas en el activity con C.DrawLine y la otra la que dibujas en el panel, a través de Panel1.SetBackgroundImage(C.Bitmap).
Si el panel tuviera el mismo tamaño que la activity solo verias una.
 

carlos7000

Well-Known Member
Licensed User
Longtime User
Como no puedo eliminar la línea

C.DrawLine(100dip, 100dip, 200dip, 200dip, Colors.Red, 1dip)

deshabilite la línea

Panel1.SetBackgroundImage(C.Bitmap)

B4X:
Sub Activity_Create(FirstTime As Boolean)
    'Do not forget to load the layout file created with the visual designer. For example:
    Activity.LoadLayout("Layout1")
    C.Initialize(Activity)
    C.DrawLine(100dip, 100dip, 200dip, 200dip, Colors.Red, 1dip)
    Activity.Invalidate
    'Panel1.SetBackgroundImage(C.Bitmap)
End Sub

Esto es lo que ahora se ve

 
Top