扩展的ImageView

时间:2018-06-09 01:43:24

标签: java android

我想将从ImageView扩展的视图添加到预先存在的布局,但也有一些例外。我的课程如下:

        public class BaseView extends ImageView{

        public static int X;
        public static int Y;
        public static int Length;
        public static int Weigth;
        int icon ;


        public BaseView(Context context, AttributeSet attrs) {
            super(context, attrs);
        }
        public BaseView(Context context, AttributeSet attrs, int defStyle) {
            super(context, attrs, defStyle);

        }

        public BaseView(Context context, int icon, int x, int y, int l, int w) {
            super(context);
            X = x;
            Y = y;
            Length = l;
            Weigth = w;
            this.icon = icon;
        }
    }

xml文件:

    <?xml version="1.0" encoding="utf-8"?>
    <RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:id="@+id/game_view_id">

        <com.example.younes.tourhanoi.BaseView
            android:layout_width="130dp"
            android:layout_height="10dp"
            android:layout_marginLeft="30dp"
            android:layout_marginTop="220dp"
            android:id="@+id/d0"
            android:background="@drawable/n5"/>

    </RelativeLayout>

请任何人帮助我,谢谢。

0 个答案:

没有答案