WEB开发网
开发学院手机开发Android 开发 Android 布局 Layout 介绍 LinearLayout 阅读

Android 布局 Layout 介绍 LinearLayout

 2010-02-24 15:42:00 来源:WEB开发网   
核心提示:Active内容如下:Java代码package com.cenphoenix.demo.linelayout;import android.app.Activity;import android.os.Bundle;import android.view.Gravity;import android.widget.L

Active内容如下:

Java代码

package com.cenphoenix.demo.linelayout;

import android.app.Activity;

import android.os.Bundle;

import android.view.Gravity;

import android.widget.LinearLayout;

import android.widget.RadioGroup;

public class LineLayout extends Activity implements

RadioGroup.OnCheckedChangeListener {

/** Called when the activity is first created. */

RadioGroup orientation;

RadioGroup gravity;

@Override

public void onCreate(Bundle icicle) {

super.onCreate(icicle);

setContentView(R.layout.main);

orientation = (RadioGroup) findViewById(R.id.orientation);

orientation.setOnCheckedChangeListener(this);

gravity = (RadioGroup) findViewById(R.id.gravity);

gravity.setOnCheckedChangeListener(this);

}

public void onCheckedChanged(RadioGroup group, int checkedId) {

if (group == orientation) {

if (checkedId == R.id.horizontal) {

orientation.setOrientation(LinearLayout.HORIZONTAL);//水平

} else {

orientation.setOrientation(LinearLayout.VERTICAL);//垂直

}

} else if (group == gravity) {

if (checkedId == R.id.left) {

gravity.setGravity(Gravity.LEFT); // 点击时该组组件居左

} else if (checkedId == R.id.center) {

gravity.setGravity(Gravity.CENTER); //center_horizontal 点击时该组组件居中

} else if (checkedId == R.id.right) {

gravity.setGravity(Gravity.RIGHT); // right 点击时该组组件居右

}

}

}

}

上一页  1 2 3 

Tags:Android 布局 Layout

编辑录入:coldstar [复制链接] [打 印]
赞助商链接