-
Notifications
You must be signed in to change notification settings - Fork 22
Xamarin Android 新建Activity
L edited this page Jan 20, 2020
·
3 revisions
在项目中新建xml文件即可,放置到/Resources/layout文件夹 这里新建activity_load_image.xml文件,添加ImageView控件
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="vertical"
android:layout_width="match_parent"
android:layout_height="match_parent">
<ImageView
android:id="@+id/imageView"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:adjustViewBounds="true"
android:visibility="visible"/>
</LinearLayout>
//Label 设置名称,设置Theme
//不能设置MainLauncher=true(不是启动的Activity)
[Activity(Label = "LoadImageActivity",Theme = "@android:style/Theme.NoTitleBar.Fullscreen")]
//注意新建的Activity默认继承的是Activity,根据需要修改
public class LoadImageActivity : Activity
{
ImageView imageView;
protected override void OnCreate(Bundle savedInstanceState)
{
base.OnCreate(savedInstanceState);
// Create your application here
//关联页面activity_load_image
SetContentView(Resource.Layout.activity_load_image);
//获得控件
imageView = FindViewById<ImageView>(Resource.Id.imageView);
}
}