0
我使用的是Signature Pad,我想用Gravity
移動我在視圖頂部添加的按鈕,但沒有任何反應,我嘗試了幾個標誌,它們看起來都一樣。我也嘗試在方法結尾處將signature
視圖添加到layout
,但這也沒有改變任何內容。爲什麼Gravity不能對我的按鈕起作用?
活性:
[Activity(Label = "Authorize Buyin", ScreenOrientation = Android.Content.PM.ScreenOrientation.Landscape)]
public class Sign : Activity
{
LinearLayout layout;
protected override void OnCreate(Bundle savedInstanceState)
{
base.OnCreate(savedInstanceState);
SetContentView(Resource.Layout.sign_dialog);
layout = FindViewById<LinearLayout>(Resource.Id.layoutSign);
CreateSignaturePad();
}
private void CreateSignaturePad()
{
var signature = new SignaturePadView(this)
{
StrokeWidth = 3f,
BackgroundColor = Android.Graphics.Color.White,
StrokeColor = Android.Graphics.Color.Black,
};
layout.AddView(signature,
new ViewGroup.LayoutParams(ViewGroup.LayoutParams.WrapContent, ViewGroup.LayoutParams.WrapContent));
/* Add Clear Button */
Button btnClear = new Button(this) { Text = "Borrar" };
signature.AddView(btnClear);
/* Add Authorize Button */
Button btnAuthorize = new Button(this) { Text = "Authorize" };
btnAuthorize.Gravity = GravityFlags.Center;
signature.AddView(btnAuthorize);
}
}
佈局:
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/layoutSign"
android:orientation="vertical"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:padding="2dp">
</LinearLayout>
你爲什麼不使用'setGravity(...)'? – Zarwan
我可能需要刪除「Android」標記。我使用Xamarin並且setGravity不存在,但是據我所知,他們使用Gravity屬性。 http://stackoverflow.com/questions/17026596/android-c-sharp-textview-setgravity – Jefecito
啊,好吧。超出我的範圍。 – Zarwan