【问题标题】:I got some trouble when i opened the xml file in Eclipse ( in Graphical Layout )我在 Eclipse 中打开 xml 文件时遇到了一些麻烦(在图形布局中)
【发布时间】:2015-01-27 13:58:07
【问题描述】:

我在 Google 中下载了一个 Android 应用程序。其中的某些布局可以在图形布局中查看,而其他布局则不能,例如此布局

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

<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:camera="http://schemas.android.com/apk/res/com.android.camera"
    android:background="@drawable/ic_launcher"
    android:id="@+id/camera"
    android:orientation="horizontal"
    android:layout_width="match_parent"
    android:layout_height="match_parent">
<com.android.camera.PreviewFrameLayout android:id="@+id/frame_layout"
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:layout_marginLeft="2dp"
        android:layout_weight="1">
    <FrameLayout android:id="@+id/frame"
            android:layout_width="match_parent"
            android:layout_height="match_parent"
            android:background="@drawable/ic_launcher">
        <SurfaceView android:id="@+id/camera_preview"
                android:layout_width="match_parent"
                android:layout_height="match_parent"/>
        <com.android.camera.FocusRectangle
                android:id="@+id/focus_rectangle"
                android:layout_width="match_parent"
                android:layout_height="match_parent"/>
    </FrameLayout>
</com.android.camera.PreviewFrameLayout>

我在下面得到了这些话:

渲染期间引发异常:com.android.layoutlib.bridge.MockView 无法转换为 android.view.ViewGroup 异常详细信息记录在窗口 > 显示视图 > 错误日志中 找不到以下类: - com.android.camera.PreviewFrameLayout(修复构建路径、编辑 XML、创建类)。

【问题讨论】:

    标签: android xml eclipse


    【解决方案1】:

    这是因为您没有类 PreviewFrameLayout。请找到它并将其包含在您的包中

    【讨论】:

    • O.对不起,我已经在那个包里有类 PreviewFrameLayout
    • 你把 PreviewFrameLayout 放在 com.android.camera 包里了吗..?
    【解决方案2】:
    com.android.camera.PreviewFrameLayout
    
    com.android.camera.FocusRectangle
    

    您应该在相应的包中包含上述自定义类。

    package com.example.scrollview;
    import android.content.Context;
    import android.util.AttributeSet;
    import android.widget.ScrollView;
    
    public class TextScroll extends ScrollView {
        private TextScrollListener scrollListener = null;
        public TextScroll(Context context) {
            super(context);
        }
    
        public TextScroll(Context context, AttributeSet attrs, int defStyle) {
            super(context, attrs, defStyle);
        }
    
        public TextScroll(Context context, AttributeSet attrs) {
            super(context, attrs);
        }
    
        public void setScrollViewListener(TextScrollListener scrollViewListener) {
            this.scrollListener = scrollViewListener;
        }
    
        @Override
        protected void onScrollChanged(int l, int t, int oldl, int oldt) {
            super.onScrollChanged(l, t, oldl, oldt);
            if (scrollListener != null) {
                scrollListener.onScrollChanged(this, l, t, oldl, oldt);
            }
        }
    }
    

    example.xml

    <com.example.scrollview
        android:layout_width="wrap_content"
        android:layout_height="wrapcontent"
    >
    </com.example.scrollview>
    

    【讨论】:

    • PreviewFrameLayout ,FocusRectangle 贴出这两个类
    猜你喜欢
    • 2016-06-29
    • 2013-01-06
    • 2019-10-21
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多