因為專案需求,要用到使用者自己畫出簽名,原本要自己做,後來發現,溫馨的Xamarin 有提供
所以寫文紀錄一下,給之後有需要碰到的人
1.在專案中Components按下右鍵選擇Get More Components
搜尋 Signature Pad
之後就下載安裝拉
2. 介紹案例說明
簽名板會放在 sContainer ,按下 btnGetImage 後會把簽名的Bitmap 放在 iomgShow 裡面
3. 之後就適時做部分 C# Code:
//宣告一個簽名版的View var signature = new SignaturePadView(this);
//粗細為10fsignature.StrokeWidth = 10f;
//將簽名板放在sContainer 之中FindViewById<LinearLayout>(Resource.Id.sContainer).AddView(signature, new ViewGroup.LayoutParams(ViewGroup.LayoutParams.FillParent, ViewGroup.LayoutParams.FillParent));//設定按鈕按下後,將bitmap 放在imgShow裡面Button btnGetImage = FindViewById<Button>(Resource.Id.btnGetImage);
btnGetImage.Click += delegate{var image = signature.GetImage();
FindViewById<ImageView>(Resource.Id.imgShow).SetImageBitmap(image);
};
signature.StrokeWidth = 10f;
sample code:
--
The bug existed in all possible states. Until I ran the code.
如果這篇文章有幫助到您幫我分享一下,讓我有寫下去的動力...