自定义类

时间:2016-04-01 18:34:23

标签: java android xml

我有一个圆形布局菜单和菜单项。设计师看起来不错,但是当我尝试运行应用程序时,它崩溃时出现以下错误android.view.InflateException: Binary XML file line #8: Error inflating class com.szugyi.circlemenu.view.CircleImageView。 我搜索了很多关于这个崩溃异常的信息,但是大多数解决方案都是关于图像大小的,并且android内存不足。

这是menu_items.xml:

<?xml version="1.0" encoding="utf-8"?>
 <merge xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:circle="http://schemas.android.com/apk/res-auto"
android:layout_width="match_parent"
android:layout_height="match_parent">



<com.szugyi.circlemenu.view.CircleImageView
    android:id="@+id/main_cloud_image"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:background="@drawable/circle"
    android:elevation="2dp"
    android:src="@drawable/ic_laptop_white_36dp"
    circle:name="cloud" />


<com.szugyi.circlemenu.view.CircleImageView
    android:id="@+id/main_mail_image"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:background="@drawable/circle"
    android:elevation="2dp"
    android:src="@drawable/ic_checkbox_blank_circle_white_18dp"
    circle:name="blank1"
     />

<com.szugyi.circlemenu.view.CircleImageView
    android:id="@+id/main_key_image"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:background="@drawable/circle"
    android:src="@drawable/ic_checkbox_blank_circle_white_18dp"
    circle:name="blank2" />

<com.szugyi.circlemenu.view.CircleImageView
    android:id="@+id/main_profile_image"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:background="@drawable/circle"
    android:elevation="2dp"
    android:src="@drawable/ic_checkbox_blank_circle_white_18dp"
    circle:name="blank3" />



    </merge>

Activity_main.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"
android:background="@color/background"
tools:context=".MainActivity"
android:onClick="screenTapped">

<com.androidsources.welcomescreen.MyRecyclerView
    android:id="@+id/cardList"
    android:layout_width="100dp"
    android:layout_height="150dp"
    android:background="@color/background"
    android:overScrollMode="never"
    android:layout_alignParentBottom="true"
    android:layout_alignParentRight="true"/>

<com.szugyi.circlemenu.view.CircleLayout
    android:id="@+id/circle_layout"
    android:layout_width="match_parent"
    android:layout_height="match_parent"

    android:layout_gravity="center_horizontal"
    android:layout_toStartOf="@+id/cardList"
    android:layout_toLeftOf="@+id/cardList"
    android:layout_marginLeft="20dp"
    android:layout_marginTop="200dp"
    android:layout_marginRight="50dp">
    <include layout="@layout/menu_items" />
</com.szugyi.circlemenu.view.CircleLayout>



<TextView
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:textAppearance="?android:attr/textAppearanceLarge"
    android:text="Freedom logo"

    android:id="@+id/textView"
    android:layout_marginTop="156dp"
    android:textColor="@color/primary"

    android:layout_alignParentTop="true"
    android:layout_centerHorizontal="true" />

<ImageView
    android:layout_width="100dp"
    android:layout_height="100dp"
    android:id="@+id/hamburger"
    android:layout_alignParentBottom="true"
    android:layout_alignParentRight="true"
    android:layout_alignLeft="@+id/cardList"
    android:layout_alignStart="@+id/cardList" />
   </RelativeLayout>

主要活动.cs:包含circleLayout=(CircleLayout)findViewById(R.id.circle_layout);

导入代码段: package com.androidsources.welcomescreen; import android.support.v7.app.AppCompatActivity; import android.os.Bundle; import android.support.v7.widget.LinearLayoutManager; import android.view.View; import android.widget.ImageView; import android.widget.TextView; import com.koushikdutta.ion.Ion; import com.szugyi.circlemenu.view.CircleLayout; import java.util.ArrayList; import java.util.List;

App build.gradle:`     申请插件:&#39; com.android.application&#39;

android {
compileSdkVersion 23
buildToolsVersion "23.0.0"

defaultConfig {
    applicationId "com.androidsources.welcomescreen"
    minSdkVersion 15
    targetSdkVersion 23
    versionCode 1
    versionName "1.0"
}
buildTypes {
    release {
        minifyEnabled false
        proguardFiles getDefaultProguardFile('proguard-android.txt'),         'proguard-rules.pro'
    }
     }
   }


  dependencies {
compile fileTree(include: ['*.jar'], dir: 'libs')
compile 'com.android.support:appcompat-v7:23.2.1'
 compile 'com.koushikdutta.async:androidasync:2.+'
 compile 'com.koushikdutta.ion:ion:2.+'
 compile 'com.android.support:cardview-v7:23.0.+'
 compile 'com.android.support:recyclerview-v7:23.0.+'
 compile 'com.github.szugyi:Android-CircleMenu:1.1.1'
 compile files('libs/nineoldandroids-2.4.0.jar')

 }

` 非常感谢你们,希望你能救我:)

0 个答案:

没有答案