android 百分数与进度显示
生活随笔
收集整理的這篇文章主要介紹了
android 百分数与进度显示
小編覺得挺不錯的,現在分享給大家,幫大家做個參考.
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
總結
以上是生活随笔為你收集整理的android 百分数与进度显示的全部內容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: javascript 中文与Unicod
- 下一篇: 小程序滚动条隐藏