Watch, Follow, &
Connect with Us

For forums, blogs and more please visit our
Developer Tools Community.


Welcome, Guest
Guest Settings
Help

Thread: Why can't I get a Rectangle with flush corners on Android?


This question is not answered. Helpful answers available: 2. Correct answers available: 1.


Permlink Replies: 0
Free Dorfman

Posts: 139
Registered: 2/4/12
Why can't I get a Rectangle with flush corners on Android?  
Click to report abuse...   Click to reply to this thread Reply
  Posted: Sep 18, 2015 10:30 PM
XE8.1 - Win8.1

Platform: Android

I'm simply trying to draw a TRectangle with a thick border.

The problem I am seeing can be demonstrated with code below.

[The reason I'm not drawing just one rectangle in this code is that I'm trying to find "the one" with perfectly square/flush corners. Also, so as not to need to post DFM/FMX stuff here.]

If I set the properties in the IDE and then deploy to Android, I'm seeing the exact same thing as this code generates. I'm talking about setting the properties of a TRectangle that's on the form. With no OnPaint code at all.

What I want on Android is the "perfectly squared" corners that I'm seeing on Windows with XRadius & YRaduis = 0.

The rectangles all look as expected under Windows, but none have square/flush corners on Android.

Also, all of these with Radii > 0 look like an epileptic's (no letters please) :`) attempts to draw a rectangle.

Am I missing something fundamental here? Am I gonna have to paint four rectangular regions (with no pen/stroke) to achieve a thick rectangular (totally flush corners) appearance? Is the mere use of a pen/stroke assuring that I have this kind of issue?

With my limited understanding of XE's approach to multiple-destination-deployment (drawing everything), I'd've thought if it were a pen/stroke issue that it'd be present everywhere (i.e. under Windows and Android). So why are none of these TRectangles (Radii > 0) rectangular on Android?

-Thanks

unit Unit1;
 
interface
 
uses
  System.SysUtils, System.Types, System.UITypes, System.Classes, System.Variants,
  FMX.Types, FMX.Controls, FMX.Forms, FMX.Graphics, FMX.Dialogs, FMX.Objects,
  FMX.Controls.Presentation, FMX.StdCtrls;
 
type
  TForm1 = class(TForm)
    procedure FormCreate(Sender: TObject);
    procedure RPaint(Sender: TObject; Canvas: TCanvas; const ARect: TRectF);
    procedure CloseBtnClick(Sender: TObject);
 
  private
    R: TRectangle;
  end;
 
var
  Form1: TForm1;
 
implementation
 
{$R *.fmx}
 
procedure TForm1.FormCreate(Sender: TObject);
var
  R: TRectangle;
begin
R := TRectangle.Create(Self);
R.Parent := Self;
R.SetBounds(20,100,600,350);
R.OnPaint := RPaint;
end;
 
procedure TForm1.RPaint(Sender: TObject; Canvas: TCanvas; const ARect: TRectF);
const
  clft    =  20;
  cwid    = 100;
  chrzsep =  50;
  ctop    =  30;
  chgt    =  50;
  cvrtsep =  30;
 
  procedure DoOneSet(row: integer; radius: single);
  var
    xpos, ypos: single;
 
    procedure DoOneRect(col: integer; CT: TCornerType);
    var
      vlft, vtop, vrgt, vbot: single;
    begin
    vlft := clft + (Pred(col) * (cwid + chrzsep));
    vtop := ctop + (Pred(row) * (chgt + cvrtsep));
    vrgt := vlft + cwid;
    vbot := vtop + chgt;
 
    Canvas.DrawRect(RectF(vlft,vtop,vrgt,vbot),radius,radius,AllCorners,1,CT);
    end;
 
  begin
  ypos := ctop + (Pred(row) * (chgt + cvrtsep));
 
  DoOneRect(1,TCornerType.Round);
  DoOneRect(2,TCornerType.Bevel);
  DoOneRect(3,TCornerType.InnerLine);
  DoOneRect(4,TCornerType.InnerRound);
  end;
 
begin
Canvas.Stroke.Thickness := 8;
 
DoOneSet(1,0);
DoOneSet(2,3);
DoOneSet(3,6);
DoOneSet(4,9);
end;
 
end.
Legend
Helpful Answer (5 pts)
Correct Answer (10 pts)

Server Response from: ETNAJIVE02