2016-12-28 65 views
-1

我正在使用Android Studio 2.3 Beta 1,並且無法呈現XML文件,從而無法使用設計。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) 
+0

我想這可能是在XML設計期間顯示的,嘗試在設計佈局中更改主題,清除並重建也可以在大多數情況下工作,並確保沒有資源丟失如果您使用某種資源 –

+0

您能分享xml代碼嗎? –

+0

試過這樣做。它沒有幫助:(。 –

回答

0

您是否使用任何自定義文字設計? SuchFieldError:TextAppearence暗示這可能是這種情況。

+0

不,我有沒有使用,因爲你可以檢查我的xml –

+0

你有沒有在主題或清單中應用任何全局文本外觀變化? –