android 控件上下排列_LinearLayout控件布局采取上下排列.doc

LinearLayout控件布局采取上下排列.doc

LinearLayout 控件布局采取上下排列

AbsoluteLayout 控件可以拖动任意位置

setText 设置文本

setTextColor 设置文本颜色

设置文本背景色

Resources resources = getBaseContext().getResources();

Drawable HippoDrawable = resources.getDrawable(R.drawable.white);

mTextView01.setBackgroundDrawable(HippoDrawable);

颜色常数 色码格式 #808080FF

CharSequence 强转字符型

mTextView02 = (TextView) findViewById(R.id.myTextView02);

CharSequence str_2 = getString(R.string.str_2);

手机屏幕分辨率

DisplayMetrics dm = new DisplayMetrics();

getWindowManager().getDefaultDisplay().getMetrics(dm);

String str = "分辨率:" + dm.widthPixels + "*" + dm.heightPixels;

控件元素样式化 其中s1为样式名称textSize为文本大小 textColor为文本颜色resources 内可以定义多个style

main.xml :

style="@style/s1"

android:text="@+id/TextView01"

android:id="@+id/TextView01"

android:layout_width="wrap_content"

android:layout_height="wrap_content"

>

style.xml :

18sp

#EC9237

按钮点击事件 注意sdk版本1.6

mButton1 =(Button) findViewById(R.id.myButton1);

mTextView1 = (TextView) findViewById(R.id.myTextView1);

mButton1.setOnClickListener(new Button.OnClickListener()

{

@Override

public void onClick(View v)

{

mTextView1.setText("哈哈");

}

});

背景白色

main.xml:

xmlns:android="/apk/res/android"

android:background="@drawable/white"

android:orientation="vertical"

android:layout_width="fill_parent"

android:layout_height="fill_parent"

>

color.xml:

#FFFFFF

页面跳转

public void jumpToLayer2()

{

setContentView(R.layout.mylayout);

mbtn4 = (Button) findViewById(R.id.Button04);

mbtn4.setOnClickListener(new Button.OnClickListener()

{

@Override

public void onClick(View v)

{

jump

  • 0
    点赞
  • 2
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值