深入理解LayoutInflater.inflate()
原文链接:https://www.bignerdranch.com/blog/understanding-androids-layoutinflater-inflate/
由于我们很容易习惯公式化的预置代码,有时我们会忽略很优雅的细节。LayoutInflater以及它在Fragment的onCreateView()中填充View的方式带给我的就是这样的感受。这个类用于将XML文件转换成相对应的ViewGroup和控件Widget。我尝试在Google官方文档与网络上其他讨论中寻找有关的说明,而后发现许多人不但不清楚LayoutInflater的inflate()方法的细节,而且甚至在误用它。
Android 开发绕不过的坑:你的 Bitmap 究竟占多大内存?
转自:http://www.jcodecraeer.com/a/anzhuokaifa/androidkaifa/2016/0116/3874.html
0、写在前面
本文涉及到屏幕密度的讨论,这里先要搞清楚 DisplayMetrics 的两个变量,摘录官方文档的解释:
- density:The logical density of the display. This is a scaling factor for the Density Independent Pixel unit, where one DIP is one pixel on an approximately 160 dpi screen (for example a 240x320, 1.5”x2” screen), providing the baseline of the system’s display. Thus on a 160dpi screen this density value will be 1; on a 120 dpi screen it would be .75; etc.
This value does not exactly follow the real screen size (as given by xdpi and ydpi, but rather is used to scale the size of the overall UI in steps based on gross changes in the display dpi. For example, a 240x320 screen will have a density of 1 even if its width is 1.8”, 1.3”, etc. However, if the screen resolution is increased to 320x480 but the screen size remained 1.5”x2” then the density would be increased (probably to 1.5). - densityDpi:The screen density expressed as dots-per-inch.
简单来说,可以理解为 density 的数值是 1dp=density px;densityDpi 是屏幕每英寸对应多少个点(不是像素点),在 DisplayMetrics 当中,这两个的关系是线性的:
vi中为每行文本开头插入行号
###vi中为每行文本开头插入行号:
1 | :g/^/exe ":s/^/".line(".") |
EditText的使用及值得注意的地方
转自:http://zmywly8866.github.io/2015/06/16/android-edittext-use.html
Android上有很多输入法应用,每种输入法都有各自的特点,输入法多数时候是和EditText配合使用,结合我自己的亲身实践分享一下使用EditText过程中遇到的一些问题及解决方法。
在 Linux 下用iptables大量屏蔽恶意 IP 地址
// 禁止CentOS7自带的firewalld,安装并启用iptables $ systemctl disable firewalld $ yum install iptables-services $ systemctl enable iptables $ cp /usr/libexec/iptables/iptables.init /etc/init.d/iptables $ /etc/init.d/iptables save // 在Linux中,可以很简单地用netfilter/iptables框架禁止IP地址: $ sudo iptables -A INPUT -s 1.1.1.1 -p TCP -j DROP // 如果你想要完全屏蔽一个IP地址段,你可以用下面的命令很简单地做到:
使用 Xcode 和 Android Studio 管理 iOS 和 Android 项目版本
在移动应用开发和运营的过程中,版本管理是一个老生常谈的基础问题,一些版本的基本概念也常常会困扰我们的研发和运营人员。同时,手动管理软件版本,也常常会因为不小心导致后续的发布和更新问题。
这里,我准备了一些 iOS 和 Android 版本的基础知识,以及如何在应用中获取版本信息和如何使用 Xcode 和 Android Studio 自动管理版本号。
Android中各种Span的用法
-
- 前言
- SpannableStringBuilder
- URLSpan
- UnderlineSpan
- TypefaceSpan
- TextAppearanceSpan
- TabStopSpanStandard
- SuperscriptSpan
- SubscriptSpan
- StrikethroughSpan
- ScaleXSpan
- StyleSpan
- RelativeSizeSpan
- QuoteSpan
- MaskFilterSpan
- LeadingMarginSpanStandard
- ImageSpan
- IconMarginSpan
- ForegroundColorSpan
- DrawableMarginSpan
- BulletSpan
- BackgroundColorSpan
- AlignmentSpanStandard
- AbsoluteSizeSpan
- ClickableSpan
- 源代码
MVC,MVP 和 MVVM 的图示
复杂的软件必须有清晰合理的架构,否则无法开发和维护。MVC(Model-View-Controller)是最常见的软件架构之一,业界有着广泛应用。它本身很容易理解,但是要讲清楚,它与衍生的 MVP 和 MVVM 架构的区别就不容易了。
昨天晚上,我读了《Scaling Isomorphic Javascript Code》,突然意识到,它们的区别非常简单。我用几段话,就可以说清。
github上fork别人项目后如何与源项目保持同步
有时候我们在github上看到一些比较好的项目,我们都会fork一下它,然后在本地进行操作,但是fork之后,项目是不会跟源项目保持同步的,需要我们自己进行一些操作让其同步。
我们以最近Nutz成员正在开发的QA系统为例,假如我们clone自己fork过来的项目的保存路径为:~/ngqa_gevinhjy