使用Android Studio 0.4.0渲染问题

时间:2013-12-28 04:13:25

标签: android xml android-studio

我最近决定在Eclipse上玩一会儿后试用Android Studio。我的主要活动xml在Eclipse上呈现正常,但Studio似乎有问题。它在预览窗口中报告:渲染问题java.lang.StackOverflowError将堆栈复制到剪贴板。

剪贴板的部分内容(完整的是> 70K个字符)是:

java.lang.StackOverflowError
    at com.android.tools.idea.rendering.ProjectCallback.loadView(ProjectCallback.java:153)
    at android.view.BridgeInflater.loadCustomView(BridgeInflater.java:207)
    at android.view.BridgeInflater.createViewFromTag(BridgeInflater.java:135)
    at android.view.LayoutInflater.rInflate_Original(LayoutInflater.java:755)
    at android.view.LayoutInflater_Delegate.rInflate(LayoutInflater_Delegate.java:64)
    at android.view.LayoutInflater.rInflate(LayoutInflater.java:727)
    at android.view.LayoutInflater_Delegate.parseInclude(LayoutInflater_Delegate.java:154)
    at android.view.LayoutInflater.parseInclude(LayoutInflater.java:782)
    at android.view.LayoutInflater.rInflate_Original(LayoutInflater.java:745)
    at android.view.LayoutInflater_Delegate.rInflate(LayoutInflater_Delegate.java:64)
    at android.view.LayoutInflater.rInflate(LayoutInflater.java:727)
    at android.view.LayoutInflater_Delegate.parseInclude(LayoutInflater_Delegate.java:154)
    at android.view.LayoutInflater.parseInclude(LayoutInflater.java:782)
    at android.view.LayoutInflater.rInflate_Original(LayoutInflater.java:745)
    at android.view.LayoutInflater_Delegate.rInflate(LayoutInflater_Delegate.java:64)
    at android.view.LayoutInflater.rInflate(LayoutInflater.java:727)
    at android.view.LayoutInflater_Delegate.parseInclude(LayoutInflater_Delegate.java:154)
    at android.view.LayoutInflater.parseInclude(LayoutInflater.java:782)
    at android.view.LayoutInflater.rInflate_Original(LayoutInflater.java:745)
    at android.view.LayoutInflater_Delegate.rInflate(LayoutInflater_Delegate.java:64)
    at android.view.LayoutInflater.rInflate(LayoutInflater.java:727)
    at android.view.LayoutInflater_Delegate.parseInclude(LayoutInflater_Delegate.java:154)
    at android.view.LayoutInflater.parseInclude(LayoutInflater.java:782)
    at android.view.LayoutInflater.rInflate_Original(LayoutInflater.java:745)
    at android.view.LayoutInflater_Delegate.rInflate(LayoutInflater_Delegate.java:64)
    at android.view.LayoutInflater.rInflate(LayoutInflater.java:727)
    at android.view.LayoutInflater_Delegate.parseInclude(LayoutInflater_Delegate.java:154)
    at android.view.LayoutInflater.parseInclude(LayoutInflater.java:782)
    at android.view.LayoutInflater.rInflate_Original(LayoutInflater.java:745)
    at android.view.LayoutInflater_Delegate.rInflate(LayoutInflater_Delegate.java:64)
    at android.view.LayoutInflater.rInflate(LayoutInflater.java:727)
    at android.view.LayoutInflater_Delegate.parseInclude(LayoutInflater_Delegate.java:154)
    at android.view.LayoutInflater.parseInclude(LayoutInflater.java:782)
    at android.view.LayoutInflater.rInflate_Original(LayoutInflater.java:745)
    at android.view.LayoutInflater_Delegate.rInflate(LayoutInflater_Delegate.java:64)
    at android.view.LayoutInflater.rInflate(LayoutInflater.java:727)
    at android.view.LayoutInflater_Delegate.parseInclude(LayoutInflater_Delegate.java:154)
    at android.view.LayoutInflater.parseInclude(LayoutInflater.java:782)
    at android.view.LayoutInflater.rInflate_Original(LayoutInflater.java:745)
    at android.view.LayoutInflater_Delegate.rInflate(LayoutInflater_Delegate.java:64)
    at android.view.LayoutInflater.rInflate(LayoutInflater.java:727)
    at android.view.LayoutInflater_Delegate.parseInclude(LayoutInflater_Delegate.java:154)
    at android.view.LayoutInflater.parseInclude(LayoutInflater.java:782)
    at android.view.LayoutInflater.rInflate_Original(LayoutInflater.java:745)
    at android.view.LayoutInflater_Delegate.rInflate(LayoutInflater_Delegate.java:64)
    at android.view.LayoutInflater.rInflate(LayoutInflater.java:727)
    at android.view.LayoutInflater_Delegate.parseInclude(LayoutInflater_Delegate.java:154)
    at android.view.LayoutInflater.parseInclude(LayoutInflater.java:782)
    at android.view.LayoutInflater.rInflate_Original(LayoutInflater.java:745)
    at android.view.LayoutInflater_Delegate.rInflate(LayoutInflater_Delegate.java:64)
    at android.view.LayoutInflater.rInflate(LayoutInflater.java:727)
    at android.view.LayoutInflater_Delegate.parseInclude(LayoutInflater_Delegate.java:154)
    at android.view.LayoutInflater.parseInclude(LayoutInflater.java:782)
    at android.view.LayoutInflater.rInflate_Original(LayoutInflater.java:745)
    at android.view.LayoutInflater_Delegate.rInflate(LayoutInflater_Delegate.java:64)
    at android.view.LayoutInflater.rInflate(LayoutInflater.java:727)
    at android.view.LayoutInflater_Delegate.parseInclude(LayoutInflater_Delegate.java:154)

实际的xml代码是:

<?xml version="1.0" encoding="utf-8"?>
<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"
    tools:context=".MainActivity" >

<TextView
    android:id="@+id/currentPosition"
    style="@style/ScreenFont_Normal"
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    android:layout_alignParentTop="true"
    android:background="#F7F7E6"
    android:textColor="#8B8B8B"
    android:text="@string/curr_loca" />

<fragment 
    android:id="@+id/map"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:layout_below="@+id/currentPosition"
    class="com.google.android.gms.maps.SupportMapFragment"
    tools:layout="@layout/activity_main"/>

<ProgressBar
    android:id="@+id/progressBar1"
    style="?android:attr/progressBarStyleLarge"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:layout_centerHorizontal="true"
    android:layout_centerVertical="true" />

</RelativeLayout> 

虽然这不会影响.apk文件的构建和创建,但我仍然希望利用Studio的酷炫图形UI编辑功能。

非常感谢任何帮助

干杯

1 个答案:

答案 0 :(得分:12)

从片段中的XML中删除以下行:

tools:layout="@layout/activity_main"/>

原因:在Android Studio中,您可以选择在处理包含片段的XML文档时编辑单独的布局。 选择编辑父版面的选项后,上面的这一行会插入到代码中。干杯