XML渲染失败

时间:2016-12-28 04:46:44

标签: android xml

我使用Android Studio 2.3 Beta 1,而且我无法呈现XML文件,这使得它无法进行设计。

我已使用以下XML代码在我的应用程序中集成配置文件详细信息视图。

<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
              xmlns:app="http://schemas.android.com/apk/res-auto"
              xmlns:tools="http://schemas.android.com/tools"
              android:layout_width="match_parent"
              android:layout_height="match_parent"
              android:focusableInTouchMode="true"
              tools:context=".activities.accounts.LoginActivity">

    <include
        android:id="@+id/appbar"
        layout="@layout/app_bar"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:layout_alignParentTop="true" />

    <RelativeLayout
        android:id="@+id/upperHalf"
        android:layout_width="match_parent"
        <!--android:layout_height="96dp"-->
        android:layout_weight="3"
        android:background="@color/colorPrimary"
        android:layout_below="@+id/appbar"
        android:transitionName="upperHalf">

        <de.hdodenhof.circleimageview.CircleImageView
            android:id="@+id/imageProfile"
            android:layout_width="80dp"
            android:layout_height="80dp"
            android:layout_centerHorizontal="true"
            android:layout_centerVertical="true"
            app:srcCompat="@drawable/ic_default_user"
            android:src="@drawable/ic_default_user"
            app:civ_border_color="@android:color/white"
            app:civ_border_width="1px" />

    </RelativeLayout>

   <ScrollView
       android:layout_width="match_parent"
       android:layout_height="wrap_content"
       android:layout_below="@+id/upperHalf">

       <LinearLayout
           android:layout_width="match_parent"
           android:layout_height="match_parent"
           android:layout_weight="1"
           android:background="@android:color/white"
           android:orientation="vertical"
           android:paddingBottom="@dimen/activity_horizontal_margin"
           android:paddingLeft="@dimen/activity_vertical_margin"
           android:paddingRight="@dimen/activity_vertical_margin"
           android:paddingTop="@dimen/activity_horizontal_margin">

           <android.support.design.widget.TextInputLayout
               android:layout_width="match_parent"
               android:layout_height="wrap_content">

               <EditText
                   android:id="@+id/firstName"
                   android:layout_width="match_parent"
                   android:layout_height="@dimen/mdtp_material_button_height"
                   android:hint="First Name" />

           </android.support.design.widget.TextInputLayout>

           <android.support.design.widget.TextInputLayout
               android:layout_width="match_parent"
               android:layout_height="wrap_content">

               <EditText
                   android:id="@+id/lastName"
                   android:layout_width="match_parent"
                   android:layout_height="@dimen/mdtp_material_button_height"
                   android:hint="Last Name" />

           </android.support.design.widget.TextInputLayout>

           <TextView
               android:layout_width="match_parent"
               android:layout_height="14dp"
               android:text="Gender"
               android:layout_marginLeft="5dp"
               android:textSize="12sp"
               android:textColor="@color/darkGrayTextColor"/>

           <Spinner
               android:id="@+id/spinnerGender"
               android:layout_width="match_parent"
               android:layout_height="34dp"
               android:textColor="@android:color/white"
               android:layout_marginLeft="5dp"
               android:layout_marginRight="5dp"
               android:background="@drawable/boder_bottom"/>

           <TextView
               android:layout_width="match_parent"
               android:layout_height="14dp"
               android:text="Country"
               android:layout_marginTop="5dp"
               android:layout_marginLeft="5dp"
               android:textSize="12sp"
               android:textColor="@color/darkGrayTextColor"/>

           <TextView
               android:id="@+id/btnCountry"
               android:layout_width="match_parent"
               android:layout_height="34dp"
               android:layout_marginLeft="5dp"
               android:layout_marginRight="5dp"
               android:text="@string/select_country"
               android:textSize="16sp"
               android:textAlignment="gravity"
               android:gravity="center_vertical"
               android:background="@drawable/boder_bottom"/>


           <android.support.design.widget.TextInputLayout
               android:layout_width="match_parent"
               android:layout_height="wrap_content"
               android:layout_marginTop="8dp">

               <EditText
                   android:id="@+id/localization"
                   android:layout_width="match_parent"
                   android:layout_height="@dimen/mdtp_material_button_height"
                   android:hint="Localization"/>

           </android.support.design.widget.TextInputLayout>


           <android.support.design.widget.TextInputLayout
               android:layout_width="match_parent"
               android:layout_height="wrap_content"
               android:layout_marginTop="8dp">

               <EditText
                   android:id="@+id/dateOfBirth"
                   android:layout_width="match_parent"
                   android:layout_height="@dimen/mdtp_material_button_height"
                   android:hint="Date of Birth"
                   android:focusable="false"
                   android:focusableInTouchMode="false"
                   android:inputType="none"/>
           </android.support.design.widget.TextInputLayout>


           <RelativeLayout
               android:layout_width="match_parent"
               android:layout_height="@dimen/mdtp_material_button_height"
               android:layout_marginTop="5dp"
               android:layout_marginLeft="5dp">

               <TextView
                   android:layout_width="match_parent"
                   android:layout_height="wrap_content"
                   android:layout_alignParentLeft="true"
                   android:layout_alignParentStart="true"
                   android:layout_centerVertical="true"
                   android:text="Is Profile Public" />

               <android.support.v7.widget.SwitchCompat
                   android:id="@+id/switchPublic"
                   android:layout_width="wrap_content"
                   android:layout_height="wrap_content"
                   android:layout_alignParentEnd="true"
                   android:layout_alignParentRight="true"
                   android:layout_centerVertical="true" />
           </RelativeLayout>

       </LinearLayout>
   </ScrollView>
</RelativeLayout>

此处我附加了Android Studio的错误。

java.lang.NoSuchFieldError: TextAppearance
at android.support.v7.widget.AppCompatTextHelper.loadFromAttributes(AppCompatTextHelper.java:88)
at android.support.v7.widget.AppCompatTextHelperV17.loadFromAttributes(AppCompatTextHelperV17.java:38)
at android.support.v7.widget.AppCompatTextView.<init>(AppCompatTextView.java:67)
at android.support.v7.widget.AppCompatTextView.<init>(AppCompatTextView.java:56)
at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:62)
at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45)
at java.lang.reflect.Constructor.newInstance(Constructor.java:423)
at org.jetbrains.android.uipreview.ViewLoader.createNewInstance(ViewLoader.java:441)
at org.jetbrains.android.uipreview.ViewLoader.loadClass(ViewLoader.java:240)
at org.jetbrains.android.uipreview.ViewLoader.loadClass(ViewLoader.java:195)
at com.android.tools.idea.rendering.LayoutlibCallbackImpl.loadClass(LayoutlibCallbackImpl.java:193)
at android.view.BridgeInflater.loadCustomView(BridgeInflater.java:333)
at android.view.BridgeInflater.onCreateView(BridgeInflater.java:152)
at android.view.LayoutInflater.onCreateView(LayoutInflater.java:717)
at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:785)
at android.view.BridgeInflater.createViewFromTag(BridgeInflater.java:222)
at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:727)
at android.view.LayoutInflater.rInflate_Original(LayoutInflater.java:858)
at android.view.LayoutInflater_Delegate.rInflate(LayoutInflater_Delegate.java:70)
at android.view.LayoutInflater.rInflate(LayoutInflater.java:834)
at android.view.LayoutInflater.inflate(LayoutInflater.java:492)
at com.android.layoutlib.bridge.bars.CustomBar.<init>(CustomBar.java:95)
at com.android.layoutlib.bridge.bars.StatusBar.<init>(StatusBar.java:67)
at com.android.layoutlib.bridge.impl.Layout.createStatusBar(Layout.java:224)
at com.android.layoutlib.bridge.impl.Layout.<init>(Layout.java:146)
at com.android.layoutlib.bridge.impl.RenderSessionImpl.inflate(RenderSessionImpl.java:301)
at com.android.layoutlib.bridge.Bridge.createSession(Bridge.java:429)
at com.android.ide.common.rendering.LayoutLibrary.createSession(LayoutLibrary.java:368)
at com.android.tools.idea.rendering.RenderTask$2.compute(RenderTask.java:567)
at com.android.tools.idea.rendering.RenderTask$2.compute(RenderTask.java:549)
at com.intellij.openapi.application.impl.ApplicationImpl.runReadAction(ApplicationImpl.java:863)
at com.android.tools.idea.rendering.RenderTask.createRenderSession(RenderTask.java:549)
at com.android.tools.idea.rendering.RenderTask.lambda$inflate$1(RenderTask.java:680)
at java.util.concurrent.FutureTask.run(FutureTask.java:266)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617)
at java.lang.Thread.run(Thread.java:745)

1 个答案:

答案 0 :(得分:0)

您使用的是自定义文字设计吗? SuchFieldError:TextAppearence建议可能就是这种情况。