android 动态布局
来源:互联网 发布:云编程 编辑:程序博客网 时间:2024/04/30 13:06
[java] view plaincopy
- /**
- * 根据手机的分辨率从 px(像素) 的单位 转成为 dp
- */
- ublic static int dip(Context context,int pxValue) {
- return (int)TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_DIP,pxValue, context.getResources().getDisplayMetrics());
xml布局与动态代码结合,取得需要的layout
- LayoutInflater inflater = LayoutInflater.from(this);
- LinearLayout linearLayout2 = (LinearLayout)inflater.inflate(R.layout.chinesean_detail, null);
1、android:layout_margin 的动态设置:
- LinearLayout.LayoutParams lp = new LinearLayout.LayoutParams(LayoutParams.FILL_PARENT,LayoutParams.FILL_PARENT);
- lp.setMargins(20,20,20,20);
- xxxLayout.addView(xxxView,lp);
2、android:layout_weight:
- LinearLayout.LayoutParams lp = new LinearLayout.LayoutParams(LayoutParams.FILL_PARENT,LayoutParams.FILL_PARENT,1.0f);
这里的第三个参数就是设置android:layout_weight的属性
3、android:layout_gravity="center_vertical"设置
- LinearLayout.LayoutParams layoutParamsImage = new LinearLayout.LayoutParams(dip(context,50),dip(context,50),2.0f);
- layoutParamsImage.gravity = Gravity.CENTER_VERTICAL;
4、设置文字粗体 android:textStyle="bold"
- textView1.getPaint().setFakeBoldText(true);
0 0
- Android 动态布局 (代码布局)
- Android 动态加载布局
- Android 动态更改布局
- Android 动态加载布局
- android 动态布局
- Android 动态加载布局
- android动态界面布局
- Android 动态加载布局
- Android 动态加载布局
- Android 动态加载布局
- Android 动态加载布局
- Android 动态加载布局
- android 动态布局
- Android 动态加载布局
- Android动态布局
- Android 动态加载布局
- Android 动态加载布局
- Android动态改变布局
- 记录今天遇到的两个问题
- about your legs and feetThe accident ha
- ServiceConnection接口的使用
- 抽象类 & 接口
- VBScript近似Visio的自动适应画布功能
- android 动态布局
- 一体化点焊机将要取代分体式焊钳在汽车制造生产线上的使用
- Cocos2d-x 3.x开发——导入Cocostudio资源
- MATLAB Floyd算法
- Android Service的生命周期和IntentService的用法
- 谈下自己做的一个办公系统的感受
- accessories any woman can have.all here
- java反射机制的作用与优点
- SQL Server 事务、异常和游标