Delphi XE10讓android的介面設計擺脫繁雜

來源:互聯網
上載者:User

標籤:

設計一個選項卡。

大體圖樣:

 

1、建立一個multi_Device_Application;2、在form上放一個Rectangle1,設定align為top。設定fill屬性的kind為Gradient,編輯Gradient(顏色取值見樣圖)。3、再放一個Rectange2設定align為top,底色為白色。4、在Rectange2上放置三個RoundRect1,RoundRect2,RoundRect3。設定它們的Corners屬性的TopLeft和TopRight為TURE,BottomLeft和BottomRight為FALSE,則圓角出現了。然後分別設定它們的Fill屬性。5、放置一個Tabcontrol控制項,設定TopPostion為None;align為client。6、設定RoundRect1,RoundRect2,RoundRect3的tag屬性分別為:1,2,3

直接上代碼:

unit TabbedTemplate;interfaceuses  System.SysUtils, System.Types, System.UITypes, System.Classes, System.Variants,  FMX.Types, FMX.Graphics, FMX.Controls, FMX.Forms, FMX.Dialogs, FMX.TabControl,  FMX.StdCtrls, FMX.Gestures, FMX.Controls.Presentation, FMX.Objects, FMX.Ani;type  TTabbedForm = class(TForm)    HeaderToolBar: TToolBar;    ToolBarLabel: TLabel;    TabControl1: TTabControl;    TabItem1: TTabItem;    TabItem2: TTabItem;    TabItem3: TTabItem;    GestureManager1: TGestureManager;    Label2: TLabel;    Label3: TLabel;    Rectangle1: TRectangle;    TabPanel: TPanel;    Line1: TLine;    RoundRect1: TRoundRect;    RoundRect2: TRoundRect;    Label5: TLabel;    Label6: TLabel;    RoundRect3: TRoundRect;    Label7: TLabel;    Rectangle2: TRectangle;    Label1: TLabel;    procedure FormCreate(Sender: TObject);    procedure FormGesture(Sender: TObject; const EventInfo: TGestureEventInfo;      var Handled: Boolean);    procedure TabControl1Gesture(Sender: TObject;      const EventInfo: TGestureEventInfo; var Handled: Boolean);    procedure TabHeadrOnClick(Sender: TObject);  private    { Private declarations }    CurTabIndex:integer;  public    { Public declarations }  end;var  TabbedForm: TTabbedForm;implementation{$R *.fmx}procedure TTabbedForm.TabHeadrOnClick(Sender: TObject);var  ClickTag:integer;  i:integer;begin  if (Sender is TLabel) then    begin       ClickTag:=Tlabel(sender).Tag    end  else    if (Sender is TRoundRect) then      begin        ClickTag:=TRoundRect(Sender).Tag;      end;  if ClickTag<>CurTabIndex then    begin      for I := 0 to self.ComponentCount-1 do        begin          if (self.Components[i] is TRoundRect) then            begin            TRoundRect(self.Components[i]).Fill.Kind:=TBrushKind.Gradient;            TRoundRect(self.Components[i]).Fill.Gradient.Color:= TAlphaColor($FFE2E4E4);            TRoundRect(self.Components[i]).Fill.Gradient.Color1:=TAlphaColor($FFFFFFFF);            TRoundRect(self.Components[i]).Fill.Gradient.Style:=TGradientStyle.Linear;            TRoundRect(self.Components[i]).Stroke.Kind:=TBrushKind.None;           end;        end;      TabControl1.ActiveTab:=TabControl1.Tabs[ClickTag-1];;      CurTabIndex:=ClickTag;      TRoundRect(sender).Fill.Kind:=TBrushKind.Solid;      TRoundRect(Sender).Fill.Color:= TAlphaColorRec.Lightskyblue;      TRoundRect(Sender).Stroke.Kind:=TBrushKind.Solid;      TRoundRect(sender).stroke.Color:=TAlphaColorRec.Lightblue;    end;end;procedure TTabbedForm.FormCreate(Sender: TObject);begin  { This defines the default active tab at runtime }  TabControl1.ActiveTab := TabItem1;  CurTabIndex:=1;end;procedure TTabbedForm.FormGesture(Sender: TObject;  const EventInfo: TGestureEventInfo; var Handled: Boolean);begin{$IFDEF ANDROID}  case EventInfo.GestureID of    sgiLeft:      begin        if TabControl1.ActiveTab <> TabControl1.Tabs[TabControl1.TabCount-1] then          begin            TabControl1.ActiveTab := TabControl1.Tabs[TabControl1.TabIndex+1];            Handled := True;          end;      end;    sgiRight:      begin        if TabControl1.ActiveTab <> TabControl1.Tabs[0] then          begin            TabControl1.ActiveTab := TabControl1.Tabs[TabControl1.TabIndex-1];            Handled := True;          end;      end;  end;{$ENDIF}end;procedure TTabbedForm.TabControl1Gesture(Sender: TObject;  const EventInfo: TGestureEventInfo; var Handled: Boolean);begin   case EventInfo.GestureID of      sgiRight:        begin         TabControl1.Previous();         Handled:=True;        end;      sgiLeft:        begin          TabControl1.Next();          Handled:=True;        end;   end;end;end.

 

Delphi XE10讓android的介面設計擺脫繁雜

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.