android.view.InflateException: бинарный XML-файл, строка № 6: ошибка надувания класса. В моем пакете я создал этот класс, но все еще возникает ошибка - PullRequest
0 голосов
/ 08 октября 2018
android.view.InflateException: Binary XML file line #6: Error inflating class com.duplicatefilefixer.SimilarPicturesPkg.astickyheader.ui.SquareImageView 

Я застрял в этом, я не знаю, что это происходит, потому что у меня есть класс по пути имени в том же пакете.

Это класс Java

 package com.duplicatefilefixer.SimilarPicturesPkg.astickyheader.ui;

    import android.content.Context;
    import android.util.AttributeSet;
    import android.widget.ImageView;

    public class SquareImageView extends ImageView {

        public SquareImageView(Context context) {
            super(context);
        }

        public SquareImageView(Context context, AttributeSet attrs) {
            super(context, attrs);
        }

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

        @Override
        protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec) {
            super.onMeasure(widthMeasureSpec, heightMeasureSpec);
            setMeasuredDimension(getMeasuredWidth(), getMeasuredWidth()); // Snap to width
        }

    }

А это мой xml

<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:tools="http://schemas.android.com/tools"
    android:layout_width="match_parent"
    android:layout_height="match_parent">

    <com.duplicatefilefixer.SimilarPicturesPkg.astickyheader.ui.SquareImageView
        android:id="@+id/image"
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:scaleType="centerInside"
        android:adjustViewBounds="true"
        android:layout_margin="2dp"
        android:src="@drawable/empty_photo" />

    <LinearLayout
        android:gravity="center"
        android:layout_alignBottom="@+id/image"
        android:layout_width="match_parent"
        android:layout_height="wrap_content">

        <TextView
            android:id="@+id/size_txt"
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:textColor="@android:color/white"
            android:background="#1758B6"
            android:text="5KB"
            android:gravity="center"
            android:visibility="gone"
            android:padding="5dp"/>

    </LinearLayout>

    <CheckBox
        android:focusable="false"
        android:button="@drawable/duplicate_checkbox"
        android:id="@+id/img_chk"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_alignTop="@+id/image"
        android:layout_alignRight="@+id/image"
        android:layout_alignEnd="@+id/image"
        android:paddingTop="5dp"
        android:paddingRight="5dp"
        android:paddingEnd="5dp"
        android:layout_marginTop="5dp"/>

</RelativeLayout>
Добро пожаловать на сайт PullRequest, где вы можете задавать вопросы и получать ответы от других членов сообщества.
...