下面是别人源码里的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>
它继承于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>
2.可以。FrameLayout,RelativeLayout 同属viewgroup,view有属于view,所以可以
把GameView当成控件加入到Layout中
===
个人博客:www.girlcoding.com
2.可以。FrameLayout,RelativeLayout 同属viewgroup,view有属于view,所以可以