日韩性视频-久久久蜜桃-www中文字幕-在线中文字幕av-亚洲欧美一区二区三区四区-撸久久-香蕉视频一区-久久无码精品丰满人妻-国产高潮av-激情福利社-日韩av网址大全-国产精品久久999-日本五十路在线-性欧美在线-久久99精品波多结衣一区-男女午夜免费视频-黑人极品ⅴideos精品欧美棵-人人妻人人澡人人爽精品欧美一区-日韩一区在线看-欧美a级在线免费观看

歡迎訪問 生活随笔!

生活随笔

當前位置: 首頁 > 运维知识 > Android >内容正文

Android

Android实例-MotionSensor加速度(XE8+小米2)

發布時間:2025/7/14 Android 23 豆豆
生活随笔 收集整理的這篇文章主要介紹了 Android实例-MotionSensor加速度(XE8+小米2) 小編覺得挺不錯的,現在分享給大家,幫大家做個參考.

?

結果:

1.

?

實例代碼:

1 unit Unit1; 2 3 interface 4 5 uses 6 System.SysUtils, System.Types, System.UITypes, System.Classes, System.Variants, 7 FMX.Types, FMX.Controls, FMX.Forms, FMX.Graphics, FMX.Dialogs, System.Sensors, 8 FMX.StdCtrls, FMX.Controls.Presentation, System.Sensors.Components; 9 10 type 11 TForm1 = class(TForm) 12 MotionSensor1: TMotionSensor; 13 Switch1: TSwitch; 14 Label1: TLabel; 15 Timer1: TTimer; 16 Label2: TLabel; 17 Label3: TLabel; 18 Label4: TLabel; 19 Label5: TLabel; 20 Label6: TLabel; 21 Label7: TLabel; 22 Label8: TLabel; 23 Label9: TLabel; 24 Label10: TLabel; 25 Label11: TLabel; 26 Label12: TLabel; 27 Label13: TLabel; 28 Label14: TLabel; 29 Label15: TLabel; 30 Label16: TLabel; 31 Label17: TLabel; 32 procedure Switch1Click(Sender: TObject); 33 procedure Timer1Timer(Sender: TObject); 34 procedure FormCreate(Sender: TObject); 35 private 36 { Private declarations } 37 public 38 { Public declarations } 39 end; 40 41 var 42 Form1: TForm1; 43 44 implementation 45 46 {$R *.fmx} 47 {$R *.NmXhdpiPh.fmx ANDROID} 48 49 procedure TForm1.FormCreate(Sender: TObject); 50 begin 51 Timer1.Enabled := False; 52 end; 53 54 procedure TForm1.Switch1Click(Sender: TObject); 55 begin 56 MotionSensor1.Active := Switch1.IsChecked; 57 Timer1.Enabled := Switch1.IsChecked; 58 end; 59 60 procedure TForm1.Timer1Timer(Sender: TObject); 61 var 62 LProp: TCustomMotionSensor.TProperty;//所有可能得到的參數 63 begin 64 for LProp in MotionSensor1.Sensor.AvailableProperties do//開始循環,如果手機支持該參數則顯示出來 65 begin 66 case LProp of 67 TCustomMotionSensor.TProperty.AccelerationX: 68 begin 69 Label10.Visible := True; 70 Label10.Text := Format('Acceleration X: %6.2f', [MotionSensor1.Sensor.AccelerationX]); 71 end; 72 TCustomMotionSensor.TProperty.AccelerationY: 73 begin 74 Label11.Visible := True; 75 Label11.Text := Format('Acceleration Y: %6.2f', [MotionSensor1.Sensor.AccelerationY]); 76 end; 77 TCustomMotionSensor.TProperty.AccelerationZ: 78 begin 79 Label12.Visible := True; 80 Label12.Text := Format('Acceleration Z: %6.2f', [MotionSensor1.Sensor.AccelerationZ]); 81 end; 82 TCustomMotionSensor.TProperty.AngleAccelX: 83 begin 84 Label13.Visible := True; 85 Label13.Text := Format('Angle X: %6.2f', [MotionSensor1.Sensor.AngleAccelX]); 86 end; 87 TCustomMotionSensor.TProperty.AngleAccelY: 88 begin 89 Label14.Visible := True; 90 Label14.Text := Format('Angle Y: %6.2f', [MotionSensor1.Sensor.AngleAccelY]); 91 end; 92 TCustomMotionSensor.TProperty.AngleAccelZ: 93 begin 94 Label15.Visible := True; 95 Label15.Text := Format('Angle Z: %6.2f', [MotionSensor1.Sensor.AngleAccelZ]); 96 end; 97 TCustomMotionSensor.TProperty.Motion: 98 begin 99 Label16.Visible := True; 100 Label16.Text := Format('Motion: %6.2f', [MotionSensor1.Sensor.Motion]); 101 end; 102 TCustomMotionSensor.TProperty.Speed: 103 begin 104 Label17.Visible := True; 105 Label17.Text := Format('Speed: %6.2f', [MotionSensor1.Sensor.Speed]); 106 end; 107 end; 108 end; 109 end; 110 111 end.

?

轉載于:https://www.cnblogs.com/FKdelphi/p/4789772.html

總結

以上是生活随笔為你收集整理的Android实例-MotionSensor加速度(XE8+小米2)的全部內容,希望文章能夠幫你解決所遇到的問題。

如果覺得生活随笔網站內容還不錯,歡迎將生活随笔推薦給好友。