我有一个名为SquareImageView
的自定义视图,我想在我的xml文件中使用它。但我的xml似乎无法解决它。为什么?我试过用小写
的xml:
<?xml version="1.0" encoding="utf-8"?>
<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent">
<pokemonmobileclient.SquareImageView
android:id="@+id/picture"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:scaleType="centerCrop" />
<TextView
android:id="@+id/text"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:paddingLeft="10dp"
android:paddingRight="10dp"
android:paddingTop="15dp"
android:paddingBottom="15dp"
android:layout_gravity="bottom"
android:textColor="@android:color/white"
android:background="#55000000"
/>
</FrameLayout>
类别:
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Android.App;
using Android.Content;
using Android.OS;
using Android.Runtime;
using Android.Text.Style;
using Android.Util;
using Android.Views;
using Android.Widget;
namespace PokemonMobileClient
{
public class SquareImageView : ImageView
{
public SquareImageView(IntPtr javaReference, JniHandleOwnership transfer) : base(javaReference, transfer)
{
}
public SquareImageView(Context context) : base(context)
{
}
public SquareImageView(Context context, IAttributeSet attrs) : base(context, attrs)
{
}
public SquareImageView(Context context, IAttributeSet attrs, int defStyleAttr) : base(context, attrs, defStyleAttr)
{
}
public SquareImageView(Context context, IAttributeSet attrs, int defStyleAttr, int defStyleRes) : base(context, attrs, defStyleAttr, defStyleRes)
{
}
protected override void OnMeasure(int widthMeasureSpec, int heightMeasureSpec)
{
base.OnMeasure(widthMeasureSpec, heightMeasureSpec);
SetMeasuredDimension(this.MeasuredWidth, this.MeasuredHeight);
}
}
}
<pokemonmobileclient.SquareImageView
有一个下划线说invalid child element pokemonmobileclient.SquareImageView
为什么我不能引用它?
由于