how to set layout width of a button from code behind in Android Xmarine in c#?

soumenhaldersoumenhalder Member ✭✭
edited September 2018 in Xamarin.Android

Hello,
I am working with a android button in xmarine android c#project.

<Button          
android:id="@+id/btn1"          
android:layout_width="120dp"          
android:layout_height="120dp"          
android:background="@drawable/ButtonImages"          
android:layout_marginLeft="35dp"   />     

Here I want to set this android:layout_width="120dp" and android:layout_marginLeft="35dp" from code behind.

I got the button control from code behind by

Button btn1 = FindViewById<Button>(Resource.Id.btn1);

but unable to set width and marginLeft

how to do this?

Best Answer

Answers

Sign In or Register to comment.