android 百分数与进度显示
程序员文章站
2022-06-08 23:49:49
...
double percent = entity.getFundraisingMoney() / entity.getInvestmentProjectAll();
//输出一下,确认你的小数无误
System.out.println("小数:" + percent);
//获取格式化对象
NumberFormat nt = NumberFormat.getPercentInstance();
//设置百分数精确度2即保留两位小数
nt.setMinimumFractionDigits(2);
//最后格式化并输出
System.out.println("百分数:" + nt.format(percent));
Log.v("lgq",".......... "+"百分数:" + nt.format(percent)+"...."+entity.getInvestmentProjectAll()+"....."+percent);
LinearLayout.LayoutParams linearParams =(LinearLayout.LayoutParams)holder.jinduteli.getLayoutParams(); //取控件textView当前的布局参数
LinearLayout.LayoutParams linearParamste =(LinearLayout.LayoutParams)holder.jindute.getLayoutParams(); //取控件textView当前的布局参
//只设置长度占比。还可以设置width 和 height holder.jindute 也就是被设置长度的view必须包裹在LinearLayout中
if (percent>0.1){
linearParams.weight =(float)percent;
linearParamste.weight =(float)percent;
}else {
linearParams.weight =(float)0.05;
linearParamste.weight =(float)0.1;
}
holder.jinduteli.setLayoutParams(linearParams);
holder.jindute.setLayoutParams(linearParamste);
改进版:
https://blog.csdn.net/meixi_android/article/details/82456945
上一篇: 文件的重命名、删除