##ProgressBar
默认为一直转圈圈的进度条
可以通过style="?android:attr/progressBarStyleHorizontal"来转化为横向进度条。
在上面设置的基础上,设置android:indeterminate=“true”,可以让横向进度条变为无真实进度的进度条,即无限循环。
重要参数:
android:max=“100”,用来指定其进度满的的时候的getProgress()值
android:indeterminate=“true”,true为循环,否则由progress控制
style="?android:attr/progressBarStyleHorizontal",指定进度条的样式。
重要方法:
progressBar.getVisibility(),下面是返回值的区别
View.VISIBLE、INVISIBLE、GONE的区别
android中UI应用的开发中经常会使用view.setVisibility()来设置控件的可见性,其中该函数有3个可选值,他们有着不同的含义:View.VISIBLE—>可见
View.INVISIBLE—>不可见,但这个View仍然会占用在xml文件中所分配的布局空间,不重新layout
View.GONE---->不可见,但这个View在ViewGroup中不保留位置,会重新layout,不再占用空间,那后面的view就会取代他的位置,
progressBar2.getProgress()
用来获取进度条的加载状况,当其值和max相等的时候,就加载满了
progressBar2.setProgress(i);
设置进度条的进度
##Notification
用来实现通知
首先需要获取一个NotificationManager进行管理
获取方式:
manager = (NotificationManager)getSystemService(NOTIFICATION_SERVICE);//获取manager
if(Build.VERSION.SDK_INT >= Build.VERSION_CODES.O){
NotificationChannel channel = new NotificationChannel("leo", "通知来了",
NotificationManager.IMPORTANCE_HIGH);
}
//创建channel,需要判断手机SDK版本
notification = new NotificationCompat.Builder(this,"leo")
.setSmallIcon(R.drawable.cry)
.setContentTitle("标题")
.setContentText("通知的内容")
.setColor(Color.parseColor("#ffff00"))
.build();
方法图:
启动通知和关闭通知的方法
manager.notify(1, notification);//启动
manager.cancel(1);//关闭
// 1为通知的id,自行取