改写这个类的 onCreate 方法如下: public void onCreate(Bundle icicle) { super.onCreate(icicle);
// 构造一个 AbsoluteLayout,设置其背景色 al = new AbsoluteLayout(this); al.setBackgroundColor(Color.YELLOW); // 构造一个 TextView 并设置其 text 和 背景色 tv = new TextView(this); tv.setText("Android is a software stack for mobile devices that includes an operating system, middleware and key applications. "); tv.setBackgroundColor(Color.BLUE); // 用该 View 在父 View 中的 width,height,x,y 作为参数构造一个 AbsoluteLayout.LayoutParams AbsoluteLayout.LayoutParams tvLP = new AbsoluteLayout.LayoutParams(70, 50, 10, 20); // 把这个 TextView 加入到 AbsoluteLayout 中,并应用上一步创建的 LayoutParams。这样 TextView 就会显示在我们指定的位置上了。 al.addView(tv, tvLP);
v = new View(this); v.setBackgroundColor(Color.RED); AbsoluteLayout.LayoutParams vLP = new AbsoluteLayout.LayoutParams(70, 50, 90, 70); // 也可以先为子 View 设置 LayoutParams,然后再调用一个参数的 ViewGroup.addView(View) 来添加。效果是一样的。 v.setLayoutParams(vLP); al.addView(v);
相关推荐
线性布局LinearLayout 框架布局FrameLayOut RelativeLayout相对布局 绝对布局AbsoluteLayout TableLayout表格布局
了解布局Layout的应用 多种Layout: AbsoluteLayout FrameLayout GridView LinearLayout ListLayout RadioGroup TableLayout ……… 3. 利用布局安排各种控件,设计良好用户界面 "<LinearLayout " "xmlns:android=...
本文实例介绍了Android中LinearLayout、AbsoluteLayout的用法,希望能对于初学Android的朋友起到一点帮助作用。具体内容如下: Android 的UI 布局都以Layout 作为容器,并且在上面按照规定排列控件,这方面跟JAVA 的...
了解布局Layout的应用 多种Layout: AbsoluteLayout FrameLayout GridView LinearLayout ListLayout RadioGroup TableLayout ……… 3. 利用布局安排各种控件,设计良好用户界面 "<LinearLayout " "xmlns:android=...
<AbsoluteLayout android:id=”@+id/widget32″ android:layout_width=”fill_parent” android:layout_height=”fill_parent” xmlns:android=”http://schemas.android.com/apk/res/android”> <TextView ...
4.1.3 布局组件(Layout) 4.1.4 布局参数(LayoutParams) 4.2 常用Widget组件 4.2.1 文本框视图(TextView) 4.2.2 按钮(Button) 4.2.3 图片按钮(ImageButton) 4.2.4 编辑框(EditText) 4.2.5 多项选择...
1.LinearLayout线性布局2.RelativeLayout相对布局3.FrameLayout帧布局,空白布局4.GridLayout网格布局5.AbsoluteLayout绝对布局1、排列方向:vertical竖向,horizontal横向如:android:orientation="vertical"2、设置...
3、ANDROID UI LAYOUT 35 3.1、概述 35 3.2、线性布局(LINEAR LAYOUT) 36 3.3、相对布局(RELATIVE LAYOUT) 39 3.4、TABLELAYOUT 40 3.5、ABSOLUTELAYOUT 47 4、ANDROID UI 控件 48 4.1、IMAGEBUTTON 48 4.1.1、...
3、ANDROID UI LAYOUT 35 3.1、概述 35 3.2、线性布局(LINEAR LAYOUT) 36 3.3、相对布局(RELATIVE LAYOUT) 39 3.4、TABLELAYOUT 40 3.5、ABSOLUTELAYOUT 47 4、ANDROID UI 控件 48 4.1、IMAGEBUTTON 48 4.1.1、...
实例137: 优化Android Layout 559 实例138: 优化Bitmap图片 560 第14章 综合实例--手机地图系统 563 实例139: 使用Google地图开发一个综合 地图系统 563 14.1 项目分析 563 14.1.1 规划UI界面 563 14.1.2 数据...