Resources\layout\Main.axml
<?xml version="1.0" encoding="utf-8"?>
<AbsoluteLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/widget35"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:background="@drawable/white">
<TextView
android:id="@+id/widget28"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="@string/str_id"
android:textColor="@drawable/darkgray"
android:layout_x="61px"
android:layout_y="69px" />
<TextView
android:id="@+id/widget29"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="@string/str_pwd"
android:textColor="@drawable/darkgray"
android:layout_x="61px"
android:layout_y="158px" />
<EditText
android:id="@+id/widget31"
android:layout_width="120dip"
android:layout_height="wrap_content"
android:textSize="18sp"
android:layout_x="114px"
android:layout_y="57px" />
<EditText
android:id="@+id/widget30"
android:layout_width="120dip"
android:layout_height="wrap_content"
android:textSize="18sp"
android:password="true"
android:layout_x="112px"
android:layout_y="142px" />
</AbsoluteLayout>
Resources\values\Strings.xml
<?xml version="1.0" encoding="utf-8"?>
<resources>
<string name="Hello">Hello World, Click Me!</string>
<string name="ApplicationName">Ex03_02</string>
<string name="str_id">帐号</string>
<string name="str_pwd">密码</string>
</resources>
Resources\values \color.xml
<?xml version="1.0" encoding="utf-8" ?>
<resources>
<drawable name="darkgray">#808080FF</drawable>
<drawable name="white">#FFFFFFFF</drawable>
</resources>
MainActivity.cs
using System;
using Android.App;
using Android.Content;
using Android.Runtime;
using Android.Views;
using Android.Widget;
using Android.OS;
namespace Ex03_02
{
[Activity(Label = "Ex03_02", MainLauncher = true, Icon = "@drawable/icon")]
public class MainActivity : Activity
{
int count = 1;
protected override void OnCreate(Bundle bundle)
{
base.OnCreate(bundle);
// Set our view from the "main" layout resource
SetContentView(Resource.Layout.Main);
}
}
}
本文介绍如何使用XML布局文件和AbsoluteLayout来设计Android应用的界面,包括使用TextView和EditText组件创建输入框,并通过字符串资源文件实现文本显示和用户交互。
833

被折叠的 条评论
为什么被折叠?



