如何将xml转换为xamarin

蛋:

我先用xamarin运行android项目。

我想将代码xml转换为xamarin或Java

完成事件后可见

<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:tools="http://schemas.android.com/tools"
    android:layout_width="match_parent"
    android:orientation="vertical"
    android:layout_height="match_parent"
    tools:context=".BlankFragment2">
 
    <TextView
        android:id="@+id/text"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:text="@string/hello_blank_fragment" />
    <Button
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:text="next"/>
    <Button
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:text="pre"/>

</LinearLayout>
Javad Dehban:

欢迎堆叠。

您可以使用链接将其转换为Java

将XML转换为Java

和xamarin:测试它

 LinearLayout layout = FindViewById<LinearLayout>(Resource.Id.parent);
            LayoutParams lp = new LayoutParams(LayoutParams.MatchParent, LayoutParams.WrapContent);

button1 = new Button(this);
                    button1.Text = "click1";
                    layout.AddView(button1, lp);

button2 = new Button(this);
                    button2.Text = "click2";
                    layout.AddView(button2, lp);

    TextView text = new TextView(this);
                    text.Text = "text";
                    layout.AddView(text, lp);

XML:

   <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:tools="http://schemas.android.com/tools"
    android:layout_width="match_parent"
    android:id="@+id/parent"
    android:orientation="vertical"
    android:layout_height="match_parent"

    tools:context=".BlankFragment2">
 
   

</LinearLayout>

本文收集自互联网,转载请注明来源。

如有侵权,请联系 [email protected] 删除。

编辑于
0

我来说两句

0 条评论
登录 后参与评论

相关文章