标签:android style io ar os 使用 sp java on
一、fill_parent、match_parent、wrap_content的区别:
super.handleMessage(msg); Bundle b = msg.getData(); switch(msg.what){ case 0: int shoudao = b.getInt("index"); system.out.println("来自子线程的值=" + shoudao); break; case ……; }}
//设置窗体始终点亮
getWindow().setFlags(WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON,
WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON);
//设置窗体背景模糊
getWindow().setFlags(WindowManager.LayoutParams.FLAG_BLUR_BEHIND,
WindowManager.LayoutParams.FLAG_BLUR_BEHIND);
四、常用方法:
五、动态改变布局的宽度、高度:
假设:1. 被改变的布局为main_leftlist_layout
2. 其父布局的属性为LinearLayout(特别注意)
那么设置其宽度、高度的代码如下:
main_leftlist_layout.setLayoutParams(new LinearLayout.LayoutParams(55, LinearLayout.LayoutParams.WRAP_CONTENT));
六、代码中添加新布局:
//布局规则r1、r2
//在layout1中添加两个对象img、tv
//img遵循规则r1,tv遵循规则r2
ImageView img = new ImageView(Activity.this);
TextView tv = new TextView(Activity.this);
LinearLayout.LayoutParams r1 = new LinearLayout.LayoutParams(new LayoutParams(18, 18));
LinearLayout.LayoutParams r2 = new LinearLayout.LayoutParams(new LayoutParams(LinearLayout.LayoutParams.WRAP_CONTENT, LinearLayout.LayoutParams.WRAP_CONTENT));
layout1.addView(img, r1);
layout1.addView(tv, r2);
七、在两个Activity之间传递参数:
八、有关Dialog:
1.设置Dialog的宽度、高度、对齐方式等:
Dialog start_dialog = new Dialog(context, R.style.MyDialog);
Window window = start_dialog.getWindow();
start_dialog.setCanceledOnTouchOutside(true);
start_dialog.setContentView(take_audio_start);
WindowManager.LayoutParams lp = window.getAttributes();
lp.width = 200;
lp.height = 300;
lp.gravity = Gravity.BOTTOM;
window.setAttributes(lp);
start_dialog.show();
九、intent中putExtras和putExtra的区别:
public Intent putExtra (String name, parcelable value)
设置方法 intent.putExtra(“aaa”, “bbbb”);
获取方法 this.getIntent().getCharSequenceExtra(“aaa”)
public Intent putExtras (Bundle extras)
设置方法
Bundle bd = new Bundle();
bd.putString(“aaa”,“bbbb”);
intent.putExtras(bd);
获取方法
Bundle bd=this.getIntent().getExtras();
bd.getString(“aaa”));
总结:带s的得通过个Bundle来绑定数据
标签:android style io ar os 使用 sp java on
原文地址:http://my.oschina.net/yuanxulong/blog/352757