شما احتیاج به یک TJNativeLayout و ContentRect دارید تا بتونید Object مورد نظر رو نمایش بدید.
در کد زیر این کار رو انجام دادم
interface
uses
System.SysUtils, System.Types, System.UITypes, System.Classes, System.Variants,
FMX.Types, FMX.Graphics, FMX.Controls, FMX.Forms, FMX.Dialogs, FMX.StdCtrls, Androidapi.JNI.GraphicsContentViewText
,Androidapi.Helpers, Androidapi.JNI.Embarcadero, Androidapi.JNI.Widget, FMX.Platform.Android,
FMX.Controls.Presentation, FMX.Platform;
type
THeaderFooterForm = class(TForm)
Header: TToolBar;
Footer: TToolBar;
HeaderLabel: TLabel;
Button1: TButton;
Panel1: TPanel;
procedure Button1Click(Sender: TObject);
private
{ Private declarations }
FRealBounds: TRect;
FBounds: TRect;
FJNativeLayout: JNativeLayout;
FJEdit: JEditText;
FScale: Single;
procedure CalcRealBorder;
procedure InitUIThread;
procedure UpdateContentFromControl;
procedure ShowUI;
procedure HideUI;
public
{ Public declarations }
end;
var
HeaderFooterForm: THeaderFooterForm;
implementation
{$R *.fmx}
procedure THeaderFooterForm.Button1Click(Sender: TObject);
//var
// ScreenSrv: IFMXScreenService;
begin
CalcRealBorder;
FScale := 1;
InitUIThread;
UpdateContentFromControl;
end;
procedure THeaderFooterForm.CalcRealBorder;
var
NativeWin: JWindow;
ContentRect: JRect;
begin
NativeWin := TAndroidHelper.Activity.getWindow;
if NativeWin <> nil then
begin
ContentRect := TJRect.Create;
NativeWin.getDecorView.getDrawingRect(ContentRect) ;
FRealBounds := Rect(ContentRect.left, ContentRect.top, ContentRect.right, ContentRect.bottom);
end
else
FRealBounds := TRect.Empty;
end;
procedure THeaderFooterForm.HideUI;
begin
if FJEdit.getVisibility <> TJView.JavaClass.INVISIBLE then
begin
FJEdit.setVisibility(TJView.JavaClass.INVISIBLE);
FJNativeLayout.setPosition(FRealBounds.Right * 2 , FRealBounds.Height * 2);
end;
end;
procedure THeaderFooterForm.InitUIThread;
begin
FJEdit := TJEditText.JavaClass.init(TAndroidHelper.Activity) ;
FJNativeLayout := TJNativeLayout.JavaClass.init(TAndroidHelper.Activ ity,
MainActivity.getWindow.getDecorView.getWindowToken );
FJNativeLayout.setPosition(100,100);
FJNativeLayout.setSize(300,300);
FJNativeLayout.setControl(FJEdit);
FJEdit.setVisibility(TJView.JavaClass.VISIBLE);
end;
procedure THeaderFooterForm.ShowUI;
begin
FJNativeLayout.setPosition(FBounds.Left, FBounds.Top);
FJNativeLayout.setSize(FBounds.Right, FBounds.Bottom);
if FJEdit.getVisibility <> TJView.JavaClass.VISIBLE then
FJEdit.setVisibility(TJView.JavaClass.VISIBLE);
end;
procedure THeaderFooterForm.UpdateContentFromControl;
var
Pos: TPointF;
begin
while FJNativeLayout = nil do
Application.ProcessMessages;
if FJNativeLayout <> nil then
begin
Pos := Panel1.LocalToAbsolute(TPointF.Zero) * FScale;
FBounds := Rect(Round(Pos.X), Round(Pos.Y), Round(50 * FScale), Round(50 * FScale));
if Panel1.Visible and Panel1.ParentedVisible and
(TCommonCustomForm(Panel1.Root.GetObject)).Visible and
(TCommonCustomForm(Panel1.Root.GetObject)).Active then
ShowUI
else
HideUI;
end
else
HideUI;
end;