编程经验分享

笑看嫣红染半山,
逐风万里白云间,
逍遥此身不为客,
天地三才任平凡。

0%

viewpager中的fragment状态变化

前提:viewpager中有多个fragment

问题:activity状态发生变化,所有的fragment的状态如何变化?

答案:

  • 如果activity调用了onPause,那么所有的缓存中的fragment都会调用onPause;
  • 在恢复的时候,activity调用了onResume,期内的所有fragment都会调用onResume

TODO:
写一个测试程序来验证一下

Android相机开发那些坑

作者:MagiLu
链接:http://zhuanlan.zhihu.com/p/20559606
来源:知乎
著作权归作者所有。商业转载请联系作者获得授权,非商业转载请注明出处。

最近我负责开发了一个跟Android相机有关的需求,新功能允许用户使用手机摄像头,快速拍摄特定尺寸(1:1或3:4)的照片,并支持在拍摄出的照片上做贴纸相关的操作。由于之前没有接触过Android相机开发,所以在整个开发过程中踩了不少坑,费了不少时间和精力。这篇文章总结了Android相机开发的相关知识、流程,以及容易遇到的坑,希望能帮助今后可能会接触Android相机开发的朋友快速上手,节省时间,少走弯路。

阅读全文 »

底部导航栏(Bottom navigation)规范指南

Original Link:https://github.com/LittleFriendsGroup/BottomNavigation/blob/master/README.md

前言:

最近 Google 在Material Design设计规范中加入底部导航栏(Bottom navigation)设计,对此,我会在文末给出个人看法!现在我们先来学习Bottom navigation

在设计、使用、交互、风格、尺寸的一些规范。水平有限,如理解有误,请多多吐槽。

阅读全文 »

有时候,我们需要将一个View固定为指定比例,比如16:9,4:3,1:1等等。
一般的做法有两种:

  • 一种是预先知道宽高的值,直接在xml中给出指定的dp值
  • 一种是根据当前的宽/高值,根据给定的比例值动态计算另一个值
阅读全文 »

如果是双向https验证,需要两个证书:

  • 服务器端需要验证的客户端证书:一般后缀是**.p12**
  • 客户端信任的服务器端证书,一般后缀是**.bks或者.truststore**
阅读全文 »

Original Link: http://antonioleiva.com/collection-operations-kotlin/

Lambdas are a great powerful tool to simplify code, but also to do things that were not possible before. We talked about them in the [first part of the series](Unleash functional power on Android (I): Kotlin lambdas).

In the end, lambdas are the basis to implement lots of functional features, such as the ones we are talking today: Collection operations. Kotlin provides an awesome set of operations that wouldn’t be possible (or really verbose) when using a language which doesn’t support lambdas.

阅读全文 »

Original Post

I’ve been talking a lot about Kotlin in this blog, but now that Google is also talking about Kotlin, and that Kotlin 1.0 RC has been released, there’s no doubt that Kotlin is much more than just an alternative for Android. Kotlin is here to stay, and I recommend you to start learning about it.

阅读全文 »