android总结

天气预报总结


  • 配置build.gradle
  • 很多人没有导包就直接写代码,导致在写代码的时候报错。
  • 我们写的RecyclerView、CardView是要导入support-v7包。
  • RecyclerView、CardView
  • DividerItemDecoration方法
    在此方法里面最重要的就是onDraw方法,它根据传进来的orientation来判断制作横向item的分割线还是纵向的item的分割线。(drawVertical是纵向的item分割线,drawHorizontal是横向的item分割线)
    代码如下:

在这里插入图片描述

  • 瀑布流
    瀑布流的好处:更稳定效率更高、自定义能力更强,为了实现方便,可以在item布局随意写一个高度来控制每个item的高度就行,通常这个高度都是由服务器返回的数据高度来控制的。
    代码如下:
    在这里插入图片描述
  • CardView布局文件里面有两个新属性
    card_view:cardCornerRadius设置圆角的半径
    card_view:cardElevation设置阴影的半径
    代码如下:

在这里插入图片描述

  • Notification一共有三种通知:普通、折叠、悬挂式
    在使用折叠式通知的时候,一定要使用RemoteViews创建自定义视图,然后再将自定义的视图赋值给Notification的视图。
    代码如下:
 //用RemoteViews来创建自定义Notification视图
     RemoteViews remoteViews = new RemoteViews(getPackageName(), R.layout.view_fold);
//指定展开时的视图
notification.bigContentView = remoteViews;

悬挂式通知则与前面两个通知不同,它需要调用setFullScreenIntent来将Notification变为悬挂式 Notification。

PendingIntent hangPendingIntent = PendingIntent.getActivity(this, 0, hangIntent, PendingIntent.FLAG_CANCEL_CURRENT);
    builder.setFullScreenIntent(hangPendingIntent, true);

实现悬挂式Notification的完整代码如下:

Notification.Builder builder = new Notification.Builder(this);
    Intent mIntent = new Intent(Intent.ACTION_VIEW, Uri.parse("http://blog.csdn.net/itachi85/"));
    PendingIntent pendingIntent = PendingIntent.getActivity(this, 0, mIntent, 0);
    builder.setContentIntent(pendingIntent);
    builder.setSmallIcon(R.drawable.foldleft);
    builder.setLargeIcon(BitmapFactory.decodeResource(getResources(), R.drawable.lanucher));
    builder.setAutoCancel(true);
    builder.setContentTitle("悬挂式通知");
    selectNotofovatiomLevel(builder);
    //设置点击跳转
    Intent hangIntent = new Intent();
    hangIntent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
    hangIntent.setClass(this, NotificationActivity.class);
    PendingIntent hangPendingIntent = PendingIntent.getActivity(this, 0, hangIntent, PendingIntent.FLAG_CANCEL_CURRENT);
    builder.setFullScreenIntent(hangPendingIntent, true);
    notificationManager.notify(2, builder.build());

以上为近期Android学习的几个知识点总结。第一次写博客,会写的不好。

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值