Android布局显示错误? [英] Android Layout Is Showing Error?

查看:247
本文介绍了Android布局显示错误?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我的Android XML布局显示以下错误,它没有显示布局的**预览**:





* *注意:此项目包含Java编译错误,这可能导致自定义视图的呈现失败。首先修复编译问题。**



**渲染期间引发的异常:android.widget.TextView无法强制转换为android.view.ViewGroup

异常详细信息记录在Window>中显示视图>错误日志**



我的** activity.xml **文件如下:





My Android XML Layout is Showing Following Error, It not Showing The **Preview** Of The Layout:


**NOTE: This project contains Java compilation errors, which can cause rendering failures for custom views. Fix compilation problems first.**

**Exception raised during rendering: android.widget.TextView cannot be cast to android.view.ViewGroup
Exception details are logged in Window > Show View > Error Log**

My **activity.xml** file is as follows:


<?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="match_parent"
   android:orientation="vertical" >

   <TextView
       android:id="@+id/textView1"
       android:layout_width="fill_parent"
       android:layout_height="wrap_content"
       android:layout_marginTop="10dp"
       android:removed="#069c88"
       android:gravity="center"
       android:text="Home"
       android:textColor="#fffff"
       android:textSize="30dp" >

       <TextView
           android:id="@+id/textView2"
           android:layout_width="match_parent"
           android:layout_height="wrap_content"
           android:gravity="center"
           android:paddingTop="20dp"
           android:text="Welcome admin"
           android:textAppearance="?android:attr/textAppearanceLarge" />
   </TextView>


   </LinearLayout>

推荐答案

使用此。,。它会工作。

Use this .,. It will Work.
<?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="match_parent"
    android:orientation="vertical" >

    <TextView
        android:id="@+id/textView1"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:layout_marginTop="10dp"
        android:gravity="center"
        android:text="Home"
        android:textColor="#121212"
        android:textSize="30dp" >
    </TextView>

    <TextView
        android:id="@+id/textView2"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:gravity="center"
        android:paddingTop="20dp"
        android:text="Welcome admin"
        android:textAppearance="?android:attr/textAppearanceLarge" />

</LinearLayout>


您的 TextView 已命名为textView1已正确终止。
Your TextView named textView1 has not been terminated properly.


这篇关于Android布局显示错误?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆