/*MainActivity.java*/

package com.example.my_ui;

import android.app.Activity;

import android.graphics.Color;

import android.annotation.SuppressLint;

import android.os.Bundle;

import android.util.TypedValue;

import android.widget.FrameLayout;

import android.widget.TextView;

public class MainActivity extends Activity {

@SuppressLint("NewApi")

@Override

protected void onCreate(Bundle savedInstanceState) {

super.onCreate(savedInstanceState);

FrameLayout frameLayout=new FrameLayout(this);//创建帧布局管理器

frameLayout.setBackground(this.getResources().getDrawable(R.drawable.welcome));//设置背景

setContentView(frameLayout);//设置在Activity中显示frameLayout

TextView textView=new TextView(this);

textView.setText("在Java中显示UI界面");//设置显示的文字

/**

 * setTextSize(TypedValue.COMPLEX_UNIT_PX,22); //22PX

setTextSize(TypedValue.COMPLEX_UNIT_SP,22); //22SP

setTextSize(TypedValue.COMPLEX_UNIT_DIP,22);//22DIP

 *

 */

textView.setTextSize(TypedValue.COMPLEX_UNIT_PT,10);

textView.setTextColor(Color.parseColor("#ff0000"));//#ff0000:红;#FCCC2C:橙;#FDFD00:黄;#00ff00:绿;#01FFFF:青;#0000ff:蓝;#A700FF:紫

//textView.setTextColor(Color.RED);

frameLayout.addView(textView);//将textView添加到布局管理器中

}

}

 

更多相关文章

  1. android百度地图半径画圆
  2. android opengl es--星星,旋涡
  3. 判断Android的网络状态
  4. android全屏问题
  5. android中进度条和选项卡的使用
  6. android socket通信
  7. android 悬浮按钮
  8. android跳转权限设置页面
  9. window.requestWindowFeature()基本用法

随机推荐

  1. android boot 代码流程
  2. Android Monkey测试脚本
  3. Android开发中的logcat工具使用
  4. 五.在Android中实现线程的方法
  5. android:contentDescription的作用是什么
  6. Android:activity context, application
  7. Android和Html的简单交互
  8. Android中事件的分发机制
  9. Android TextView、EditText显示表情
  10. Android(安卓)Push Notification实现信息