下面是别人源码里的layout\main.xml文件:1)five.itcast.cn.Chessboard是一个自定义的类,public class Chessboard extends View implements IChessboard{。
它继承于View的。竟可以与TextView一样,加入到layout中?2)<RelativeLayout也是一种布局方式,它是可以内嵌于<FrameLayout吗?<?xml version="1.0" encoding="utf-8"?>
<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="@android:color/white"> <five.itcast.cn.Chessboard android:id="@+id/snake"
android:layout_width="match_parent"
android:layout_height="match_parent"
tileSize="24"
/>

<RelativeLayout
android:layout_width="match_parent"
android:layout_height="match_parent">
<TextView
android:id="@+id/text"
android:text="@string/mode_ready"
android:visibility="visible"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerHorizontal="true"
android:layout_centerVertical="true"
android:textColor="#ff0000"
android:textSize="24sp"
/>
</RelativeLayout></FrameLayout>

解决方案 »

  1.   

    1.是的。layout可以加入view,他继承view,所以可以。
    2.可以。FrameLayout,RelativeLayout 同属viewgroup,view有属于view,所以可以
      

  2.   

    确实可以,Android游戏中我就采用过
    把GameView当成控件加入到Layout中
      

  3.   

    这样是可以的!因为它是继承View,而layout也同属于View!如果不继承view就不可以了!这中用法一般都是高手常用手段!并且有时候也很便利!
      

  4.   

    都可以,可以在layout中使用自定义的view,也可以嵌套layout
      

  5.   

    理解View跟ViewGroup的关系ViewGroup继承View五大布局FrameLayout,RelativeLayout,LinearLayout,AbsoluteLayout,TabelLayout都继承ViewGroupTextView也是继承View,那么自定义View继承View,性质与TextView是等同的。布局里面根节点必须是一个ViewGroup/五大布局,用来放置View,因为ViewGroup继承View,所以布局里面还可以嵌套布局。
    ===
    个人博客:www.girlcoding.com
      

  6.   

    1.是的。layout可以加入view,他继承view,所以可以。
    2.可以。FrameLayout,RelativeLayout 同属viewgroup,view有属于view,所以可以