Chinaunix首页 | 论坛 | 博客
  • 博客访问: 535899
  • 博文数量: 179
  • 博客积分: 3845
  • 博客等级: 中校
  • 技术积分: 2003
  • 用 户 组: 普通用户
  • 注册时间: 2010-08-16 21:25
文章分类
文章存档

2012年(74)

2011年(105)

分类: 嵌入式

2011-12-30 10:47:11

       上一篇我们已经可以在同一界面中既显示我们的surfaceview和button、textview等组件,那么基本算是成功了,但是身为游戏开 发人员,如果不是想故意要这种类似电影形式的展现方式(我们的surfaceview在中间 - -.很想播放电影似的。。),是绝对不允许游戏的分量只是占了中间那么一部分,肯定需要全屏显示,别的组件只是一个配角的角色。那么下面先上一张截图看下 为什么修改与调整。

 

                                                                                  (图1)

                           

 

 

看到我们画出来的字体了吧,很悲剧被覆盖了!只要有button就会有一块长条,即使我们修改button中布局的颜色也只是把长条的颜色变成白色,当然好看是好看了,但是仍旧遮挡我们的字体!这可不是我们想要的结果。我们想要的效果应该是下图这样的:

 

                                                                                  (图2)

                                 

 

娃哈哈,这效果就对啦,我们的view占满全屏,而组件本身才会对我们的view中的内容有遮挡,不会多出一些无用的长条遮挡....

 

当时虽然想的方法就是布局xml的问题,我一开始想在我们xml中定义的surfaceview中直接添加按钮,但是view不能添加view!所以没办法,就想到是否是布局的问题。经过多次尝试才终于成功做到。

  1. <?xml version="1.0" encoding="utf-8"?>
  2. <LinearLayout xmlns:android="" android:orientation="vertical"
  3.   android:layout_width="fill_parent"
  4.   android:layout_height="fill_parent"
  5.        >
  6.         <RelativeLayout
  7.                 android:layout_width="fill_parent"
  8.                 android:layout_height="wrap_content"
  9.                android:layout_weight="1" >
  10.        <com.himi.MySurfaceView android:id="@+id/view3d"
  11.                android:layout_width="fill_parent"
  12.                android:layout_height="fill_parent"/>
  13.            <Button
  14.             android:layout_width="wrap_content"
  15.                    android:layout_height="wrap_content"
  16.                    android:layout_alignParentBottom="true"
  17.                    android:text="Himi Button_1"
  18.                     android:id="@+id/button1"/>
  19.          
  20.            <Button android:layout_width="wrap_content"
  21.                    android:layout_height="wrap_content"
  22.                    android:layout_alignParentBottom="true"
  23.                    android:layout_toRightOf="@id/button1"
  24.                    android:text="Himi Button_2"
  25.                      android:id="@+id/button2"/>
  26.                         <TextView
  27.                android:id="@+id/textview"
  28.                android:layout_width="fill_parent"
  29.               android:layout_height="fill_parent"
  30.                android:text="This is Himi"
  31.                android:textSize="32sp"
  32.                android:textColor="#00FF00"
  33.                android:gravity="center_horizontal"/>
  34.        </RelativeLayout>
  35.    </LinearLayout>
阅读(474) | 评论(0) | 转发(0) |
给主人留下些什么吧!~~