Android动态添加TextView
16lz
2022-01-24
LinearLayout.LayoutParams params=new LinearLayout.LayoutParams(LayoutParams.MATCH_PARENT,LayoutParams.WRAP_CONTENT);
for (int i = 0; i < items.size(); i++) { TextView mTv= new TextView(mContext); mTv.setLayoutParams(params); mTv.setLineSpacing(1.2f, 1.2f);//设置行间距 mTv.setTextColor(mContext.getResources().getColor(R.color.text_light_black)); mTv.setTextSize(TypedValue.COMPLEX_UNIT_SP,15); mTv.setText(i+1+"."+items.get(i).getSubName()); System.out.println("mTv="+mTv.getText()+items.get(i).getSubName()); holder.ll_content.addView(mTv,i,params); }
更多相关文章
- android之Tab选项卡控件
- android radiobutton选中字体颜色改变的方法
- 【Android】Vibrator(震动模式)设置长短震动
- Android模仿Buttonbar
- android 线程优先级设置方法
- 【Android】 dialog 设置maxHeight 最大高度
- android 基础知识
- Android窗口机制(一)——Window,PhoneWindow,DecorView理解
- android 上传文件到服务器