2016-06-15 7 views
0

これは問題を引き起こしているレイアウトです。ここでエラー:layout_width属性エラーを指定する必要があります。私はそれを供給しましたが

<?xml version="1.0" encoding="utf-8"?> 

<!-- Drawer Layout --> 

<android.support.v4.widget.DrawerLayout 
    xmlns:android="http://schemas.android.com/apk/res/android" 
    xmlns:app="http://schemas.android.com/apk/res-auto" 
    android:layout_width="match_parent" 
    android:layout_height="match_parent" 
    android:id="@+id/drawer_layout" 
    android:fitsSystemWindows="true"> 

    <!--Main content--> 

    <RelativeLayout 
     android:layout_width="match_parent" 
     android:layout_height="match_parent"> 

     <android.support.v7.widget.Toolbar xmlns:android="http://schemas.android.com/apk/res/android" 
      xmlns:app="http://schemas.android.com/apk/res-auto" 
      android:id="@+id/mtoolbar" 
      android:minHeight="?attr/actionBarSize" 
      android:background="?attr/colorPrimary" 
      android:layout_width="match_parent" 
      app:theme="@style/ThemeOverlay.AppCompat.Dark" 
      app:popupTheme="@style/ThemeOverlay.AppCompat.Light" 
      android:layout_height="wrap_content"> 

     </android.support.v7.widget.Toolbar> 


     <TextView 
      android:text="@string/hello_world" 
      android:layout_width="wrap_content" 
      android:layout_height="wrap_content" 
      android:layout_below="@id/mtoolbar" 
      android:layout_centerInParent="true"/> 

    </RelativeLayout> 

    <!--Navigation Drawer--> 
    <android.support.design.widget.NavigationView 
     android:id="@+id/main_drawer" 
     android:layout_width="wrap_content" 
     android:layout_height="match_parent" 
     android:layout_gravity="start" 
     app:headerLayout="@layout/drawer_header" 
     app:menu="@menu/menu_drawer"/> 
</android.support.v4.widget.DrawerLayout> 

drawer_header.xml

<?xml version="1.0" encoding="utf-8"?> 
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" 
    android:layout_width="match_parent" 
    android:layout_height="150dp" 
    android:background="@drawable/header" 
    android:padding="16dp" 
    android:orientation="vertical" 
    android:gravity="bottom"> 

    <TextView 
     android:textColor="#ffffff" 
     android:textSize="18sp" 
     android:layout_width="match_parent" 
     android:layout_height="wrap_content" 
     android:text="Hello World " 
    /> 
</LinearLayout> 

されており、ここで私はそれはまだエラーを示しているDrawerLayoutためlayout_widthパラメータを供給してきましたが、logcat出力

06-15 21:38:05.125 14798 14798 I art           Late-enabling -Xcheck:jni 
06-15 21:38:05.323 14798 14798 W System          ClassLoader referenced unknown path: /data/app/xyz.sayangoswami.opoforums-2/lib/arm 
06-15 21:38:05.472 14798 14798 I AppCompatViewInflater      app:theme is now deprecated. Please move to using android:theme instead. 
06-15 21:38:05.515 14798 14798 D AndroidRuntime        Shutting down VM 
06-15 21:38:05.520 14798 14798 E AndroidRuntime        FATAL EXCEPTION: main 
06-15 21:38:05.520 14798 14798 E AndroidRuntime        Process: xyz.sayangoswami.opoforums, PID: 14798 
06-15 21:38:05.520 14798 14798 E AndroidRuntime        java.lang.RuntimeException: Unable to start activity ComponentInfo{xyz.sayangoswami.opoforums/xyz.sayangoswami.opoforums.MainActivity}: android.view.InflateException: Binary XML file line #39: Binary XML file line #39: Error inflating class android.support.design.widget.NavigationView 
06-15 21:38:05.520 14798 14798 E AndroidRuntime        at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2416) 
06-15 21:38:05.520 14798 14798 E AndroidRuntime        at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2476) 
06-15 21:38:05.520 14798 14798 E AndroidRuntime        at android.app.ActivityThread.-wrap11(ActivityThread.java) 
06-15 21:38:05.520 14798 14798 E AndroidRuntime        at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1344) 
06-15 21:38:05.520 14798 14798 E AndroidRuntime        at android.os.Handler.dispatchMessage(Handler.java:102) 
06-15 21:38:05.520 14798 14798 E AndroidRuntime        at android.os.Looper.loop(Looper.java:148) 
06-15 21:38:05.520 14798 14798 E AndroidRuntime        at android.app.ActivityThread.main(ActivityThread.java:5417) 
06-15 21:38:05.520 14798 14798 E AndroidRuntime        at java.lang.reflect.Method.invoke(Native Method) 
06-15 21:38:05.520 14798 14798 E AndroidRuntime        at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:726) 
06-15 21:38:05.520 14798 14798 E AndroidRuntime        at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:616) 
06-15 21:38:05.520 14798 14798 E AndroidRuntime        Caused by: android.view.InflateException: Binary XML file line #39: Binary XML file line #39: Error inflating class android.support.design.widget.NavigationView 
06-15 21:38:05.520 14798 14798 E AndroidRuntime        at android.view.LayoutInflater.inflate(LayoutInflater.java:539) 
06-15 21:38:05.520 14798 14798 E AndroidRuntime        at android.view.LayoutInflater.inflate(LayoutInflater.java:423) 
06-15 21:38:05.520 14798 14798 E AndroidRuntime        at android.view.LayoutInflater.inflate(LayoutInflater.java:374) 
06-15 21:38:05.520 14798 14798 E AndroidRuntime        at android.support.v7.app.AppCompatDelegateImplV7.setContentView(AppCompatDelegateImplV7.java:280) 
06-15 21:38:05.520 14798 14798 E AndroidRuntime        at android.support.v7.app.AppCompatActivity.setContentView(AppCompatActivity.java:140) 
06-15 21:38:05.520 14798 14798 E AndroidRuntime        at xyz.sayangoswami.opoforums.MainActivity.onCreate(MainActivity.java:28) 
06-15 21:38:05.520 14798 14798 E AndroidRuntime        at android.app.Activity.performCreate(Activity.java:6251) 
06-15 21:38:05.520 14798 14798 E AndroidRuntime        at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1107) 
06-15 21:38:05.520 14798 14798 E AndroidRuntime        at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2369) 
06-15 21:38:05.520 14798 14798 E AndroidRuntime        ... 9 more 
06-15 21:38:05.520 14798 14798 E AndroidRuntime        Caused by: android.view.InflateException: Binary XML file line #39: Error inflating class android.support.design.widget.NavigationView 
06-15 21:38:05.520 14798 14798 E AndroidRuntime        at android.view.LayoutInflater.createView(LayoutInflater.java:645) 
06-15 21:38:05.520 14798 14798 E AndroidRuntime        at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:764) 
06-15 21:38:05.520 14798 14798 E AndroidRuntime        at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:704) 
06-15 21:38:05.520 14798 14798 E AndroidRuntime        at android.view.LayoutInflater.rInflate(LayoutInflater.java:835) 
06-15 21:38:05.520 14798 14798 E AndroidRuntime        at android.view.LayoutInflater.rInflateChildren(LayoutInflater.java:798) 
06-15 21:38:05.520 14798 14798 E AndroidRuntime        at android.view.LayoutInflater.inflate(LayoutInflater.java:515) 
06-15 21:38:05.520 14798 14798 E AndroidRuntime        ... 17 more 
06-15 21:38:05.520 14798 14798 E AndroidRuntime        Caused by: java.lang.reflect.InvocationTargetException 
06-15 21:38:05.520 14798 14798 E AndroidRuntime        at java.lang.reflect.Constructor.newInstance(Native Method) 
06-15 21:38:05.520 14798 14798 E AndroidRuntime        at android.view.LayoutInflater.createView(LayoutInflater.java:619) 
06-15 21:38:05.520 14798 14798 E AndroidRuntime        ... 22 more 
06-15 21:38:05.520 14798 14798 E AndroidRuntime        Caused by: android.view.InflateException: Binary XML file line #2: Binary XML file line #2: You must supply a layout_width attribute. 
06-15 21:38:05.520 14798 14798 E AndroidRuntime        at android.view.LayoutInflater.inflate(LayoutInflater.java:539) 
06-15 21:38:05.520 14798 14798 E AndroidRuntime        at android.view.LayoutInflater.inflate(LayoutInflater.java:423) 
06-15 21:38:05.520 14798 14798 E AndroidRuntime        at android.support.design.internal.NavigationMenuPresenter.inflateHeaderView(NavigationMenuPresenter.java:189) 
06-15 21:38:05.520 14798 14798 E AndroidRuntime        at android.support.design.widget.NavigationView.inflateHeaderView(NavigationView.java:263) 
06-15 21:38:05.520 14798 14798 E AndroidRuntime        at android.support.design.widget.NavigationView.<init>(NavigationView.java:174) 
06-15 21:38:05.520 14798 14798 E AndroidRuntime        at android.support.design.widget.NavigationView.<init>(NavigationView.java:96) 
06-15 21:38:05.520 14798 14798 E AndroidRuntime        ... 24 more 
06-15 21:38:05.520 14798 14798 E AndroidRuntime        Caused by: java.lang.UnsupportedOperationException: Binary XML file line #2: You must supply a layout_width attribute. 
06-15 21:38:05.520 14798 14798 E AndroidRuntime        at android.content.res.TypedArray.getLayoutDimension(TypedArray.java:709) 
06-15 21:38:05.520 14798 14798 E AndroidRuntime        at android.view.ViewGroup$LayoutParams.setBaseAttributes(ViewGroup.java:6889) 
06-15 21:38:05.520 14798 14798 E AndroidRuntime        at android.view.ViewGroup$MarginLayoutParams.<init>(ViewGroup.java:7071) 
06-15 21:38:05.520 14798 14798 E AndroidRuntime        at android.widget.LinearLayout$LayoutParams.<init>(LinearLayout.java:1911) 
06-15 21:38:05.520 14798 14798 E AndroidRuntime        at android.widget.LinearLayout.generateLayoutParams(LinearLayout.java:1816) 
06-15 21:38:05.520 14798 14798 E AndroidRuntime        at android.widget.LinearLayout.generateLayoutParams(LinearLayout.java:1815) 
06-15 21:38:05.520 14798 14798 E AndroidRuntime        at android.view.LayoutInflater.inflate(LayoutInflater.java:502) 
06-15 21:38:05.520 14798 14798 E AndroidRuntime        ... 29 more 

です。それが助け場合

、私は事前にAPPCOMPATのV7とcompileSdkVersion 21と設計サポートライブラリとbuildToolsVersion 21.1.0

感謝を使用しています。

問題は解決しました。

HTTP://SCHEMAS.ANDROID.COM/APK/RES/ANDROIDdrawer_header.xml 2行目にhttp://schemas.android.com/apk/res/androidという大文字の問題がありました。

+1

エラーは、それが 'inflateHeaderView()'と言う - ことができますあなたの 'drawer_header.xml'を含めますか? – ianhanniballake

+0

'NavigationView'のxmlファイルの2行目は何ですか? – Vucko

+0

@anhanniballake確かに待ってください。 – sayan

答えて

2

あなたのdrawer_header.xmlファイルにエラーが表示されなければならない、名前空間はすべて大文字であってはならない。

xmlns:android="http://schemas.android.com/apk/res/android" 

ない:

xmlns:android="HTTP://SCHEMAS.ANDROID.COM/APK/RES/ANDROID" 
+0

私は質問をしました。名前空間は大文字と小文字を区別する必要がありますか? – sayan

+0

彼らは明らかにそうですが、彼らがすべきかどうか、誰が知っていますか? :Dとにかく、すべての大文字はネームスペースを叫んでいるように見えます:D – Vucko

+0

@ Sayan98本当に、私はそうすべきだとは思っていませんが、そうです。 – Bryan

関連する問題