`
weihe6666
  • 浏览: 430618 次
  • 性别: Icon_minigender_1
  • 来自: 深圳
社区版块
存档分类
最新评论

LinearLayout and FrameLayout

XML 
阅读更多
LinearLayout and FrameLayout

  • LinearLayout 单层线性布局,子控件不可覆盖,而以垂直或水平布局。

  • FrameLayout 单帧空间垂直布局,display a singer item,but you can populate it with many items, setting one to visible while the others are invisible.只有一个子控件可见,其它均被隐藏。每个添加的子控件都被放在布局的左上角,并覆盖前一子控件的上层。


LinearLayout 做出如下效果:

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:orientation="vertical"
    android:layout_width="fill_parent"
    android:layout_height="160px"
    android:background="@android:color/white"
    >
   <TextView  
    android:layout_width="fill_parent" 
    android:layout_height="wrap_content" 
    android:text="@string/hello"
    />
    
    <com.studio.android.Chessboard android:id="@+id/snake" android:layout_width="match_parent"
		android:layout_height="match_parent" tileSize="24"/>   
          <LinearLayout 
         xmlns:android="http://schemas.android.com/apk/res/android"
         android:orientation="horizontal"
         android:layout_width="wrap_content"
         android:layout_height="wrap_content"
          android:background="@android:color/black"
          >
    </LinearLayout>
</LinearLayout>


分析:The first LinearLayout 垂直布局,所以TextView and Chessboard 垂直分布。第二个LinearLayout则位于其下。也就是两个LinearLayout不相互重叠,依次排列。

FrameLayout的布局:

<?xml version="1.0" encoding="utf-8"?>
<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:orientation="vertical"
    android:layout_width="fill_parent"
    android:layout_height="fill_parent"
    android:background="@drawable/bg"
    >
	<RelativeLayout
		android:layout_width="match_parent"
		android:layout_height="match_parent">
		<TextView
			android:id="@+id/text"
			android:text="@string/hello"
			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>
<Button
   android:layout_width="50px"
   android:layout_height="wrap_content"
   android:text="确定"
   />
</FrameLayout>

分析:在整个的FrameLayout的布局中,上层子控件覆盖下层子控件,每个子控件都被放在左上角(0,0)位置。
分享到:
评论

相关推荐

    FragmentTabHost FrameLayout实现底部导航栏

    app经常用到底部导航栏,早前使用过RadioGroup+FrameLayout实现或者RadioGroup+ViewPager实现,现在基本使用FragmentTabHost+FrameLayout来实现,因为使用起来简单易用。...LinearLayout xmlns:and

    Android代码-自定义评分控件

    PercentClipView :star: Cropped layouts with percentage for ...LinearLayout layout = (LinearLayout) this.findViewById(R.id.layout); layout.setClipLeft(0.50f); Reference Class FrameLayout LinearLayo

    RoundCorners:可以指定圆角的ViewGroupView(可带边框)。A ViewGroupView with rounded corners(and stroke) for Android

    效果预览特点LinearLayout、RelativeLayout、FrameLayout支持圆角ImageView、TextView、View、Button支持圆角CircleImageView(圆形图片)支持边框(不遮挡图片)可正常设置ripple(波纹不会突破边框)使用 xml 或者...

    Introduction.to.Android.Application.Development(4th,2013.12) pdf

    Using LinearLayout 217 Using RelativeLayout 219 Using FrameLayout 222 Using TableLayout 224 Using GridLayout 228 Using Multiple Layouts on a Screen 230 Using Container Control Classes 232 Using Data-...

    Android实验指导.doc

    了解布局Layout的应用 多种Layout: AbsoluteLayout FrameLayout GridView LinearLayout ListLayout RadioGroup TableLayout ……… 3. 利用布局安排各种控件,设计良好用户界面 "&lt;LinearLayout " "xmlns:android=...

    Android实验指导(1).doc

    了解布局Layout的应用 多种Layout: AbsoluteLayout FrameLayout GridView LinearLayout ListLayout RadioGroup TableLayout ……… 3. 利用布局安排各种控件,设计良好用户界面 "&lt;LinearLayout " "xmlns:android=...

    使用ViewPager实现android软件使用向导功能实现步骤

    首先需要一个布局文件,是FlameLayout组成的,里面包含了一个ViewPager和一个RelativeLayout,RelativeLayout里面是一个LinearLayout,LinearLayout里面是准备放ImageView,动态添加。 布局文件如下: 代码如下:&lt...

    Android重写Gallery

    重写的Gallery,Gallery滑动的时候下面的点跟着动 ... import java.util.ArrayList; import android.app.Activity; import android.content.Context;... new LinearLayout.LayoutParams(LayoutParams.FILL_PARENT...

    android开发demo集合

    1、LinearLayout Button、RadioGroup、 CheckBox 2、TableLayout 3、FrameLayout 霓虹灯效果 4、RelativeLayout 梅花效果 5、自定义view跟着触点走的小球 6、 ListView 列表视图 7、WebView web视图 8、...

    android初学者入门项目

    1、LinearLayout Button、RadioGroup、 CheckBox 2、TableLayout 3、FrameLayout 霓虹灯效果 4、RelativeLayout 梅花效果 5、自定义view跟着触点走的小球 6、 ListView 列表视图 7、WebView web视图 8、...

    android 图片操作(缩放移动) 实例代码

    view_show.xml 代码如下:&lt;?xml version=”1.0″ encoding=”utf-8″?&gt;&lt;LinearLayout xmlns:android=”http://schemas.android.com/apk/res/android” ...FrameLayout android:layout_height=”fill_parent” 

    android商品详情页面设计详解

    先大致说一下,整体结构使用的是LinearLayout实现,分上下两部分,上边就是我们能滑动的自定义布局,下面就是“进入店铺”,“立即购买”这两个无关紧要的布局; 下面是根据产品的要求更改的,每个APP几乎都不一样,...

    Android移动应用开发实验指导书.docx.docx

    (2)Android的布局方式有LinearLayout(线性布局)、FrameLayout(单帧布局)、RelativeLayout(相对布局)、TableLayout(表格布局)。 (3)Adapter是连接后端数据和前端显示的适配器接口,是数据和UI(View)...

    Android移动应用开发实验指导书.docx

    (2)Android的布局方式有LinearLayout(线性布局)、FrameLayout(单帧布局)、RelativeLayout(相对布局)、TableLayout(表格布局)。 (3)Adapter是连接后端数据和前端显示的适配器接口,是数据和UI(View)...

    android中Fragment+RadioButton实现底部导航栏

    在App中经常看到这样的tab底部导航栏 那么这种效果是如何实现,实现的方式有很多种,最常见的就是使用Fragment+RadioButton去实现。...LinearLayout xmlns:android=http://schemas.android.com/apk/res/android

Global site tag (gtag.js) - Google Analytics