Android知识点记录

git 使用

git push origin master

origin 指的是远程版本库的 git 地址
master 指的是同步到哪个分支,这儿是 master 分支

本地貌似有个缓存为 origin/master 分支

因为我在 github 在线修改了 README.md 文件,github 网站上的是修改了。但是本地执行git status命令,得到下面的提示

TomChens-MacBook-Pro:android tomchen$ git statusOn branch masterYour branch is up-to-date with 'origin/master'.

说本地的分支是和origin/master同步的。

这时候需要用

git pull origin master

实现从远程获取最新代码,合并到本地。

Animation 构造器

public RotateAnimation (float fromDegrees, float toDegrees, int pivotXType, float pivotXValue, int pivotYType, float pivotYValue)参数说明fromDegrees:旋转的开始角度。toDegrees:旋转的结束角度。pivotXType:X轴的伸缩模式,可以取值为ABSOLUTE(绝对值)、RELATIVE_TO_SELF(相对自身)、RELATIVE_TO_PARENT(相对父空间)。pivotXValue:X坐标的伸缩值。pivotYType:Y轴的伸缩模式,可以取值为ABSOLUTE、RELATIVE_TO_SELF、RELATIVE_TO_PARENT。pivotYValue:Y坐标的伸缩值。

注意:旋转表示一个控件绕着一个点做旋转(平面旋转)。这个旋转是围绕一个点,而这个点是由百分比决定的,比如相对于自身时x为0.5,y为0.5,那么这个点就是该控件的中心;如果x为1,y为1,那么这个点就是控件的右下角;相对父控件时x为0.5,y为0.5,那么这个点就是该父控件的中心。

围绕控件中心旋转的方法:(旋转的控件布局要是一个正方形,即比较严格对称的)

RotateAnimation  rotateAnimation = new RotateAnimation(0, 180,Animation.RELATIVE_TO_SELF, 0.5f, Animation.RELATIVE_TO_SELF,0.5f);

Android:visibility

Note
Android控件有visibility属性,可以在xml文件中用android:visibility指定,或者用public void setVisibility (int visibility)方法指定

其属性有3个分别为“visible”、“invisible”、“gone”。
visible表示可见,invisible和gone都不可见

但是gone不占用原来的位置和大小,invisible还占有原有空间

AlertDialog

Note*
AlertDialog类中有一个setCancelable(boolean)方法,表示是否可以用手机上的back键取消对话框。

摘自google官方api
java.lang.Object
↳ android.app.Dialog
↳ android.app.AlertDialog
public void setCancelable (boolean flag)
Added in API level 1
Sets whether this dialog is cancelable with the BACK key.

LayoutInflater.from(context).inflate(R.layout.title, null)

在自定义UI中,经常使用 LayoutInflater.from(context).inflate(R.layout.title, null)
或 LayoutInflater.from(getContext()).inflate(R.layout.title, this)

关于第2个参数是null 还是非null的问题,查看了API。

API
java.lang.Object
↳ android.view.LayoutInflater
public View inflate (int resource, ViewGroup root)

Added in API level 1
Inflate a new view hierarchy from the specified xml resource. Throws InflateException if there is an error.

Parameters
resource ID for an XML layout resource to load (e.g., R.layout.main_page)
root Optional view to be the parent of the generated hierarchy.
Returns
The root View of the inflated hierarchy. If root was supplied, this is the root View; otherwise it is the root of the inflated XML file.
如果第2个参数非空,返回值为第2个参数;个人认为返回值为第1个参数(此处有疑惑)
inflate(R.layout.res, parent, true) 等价于 inflate(R.layout.res, parent)
inflate(R.layout.res, parent, false) 不等价于nflate(R.layout.res, null)

ListView 优化性能

在继承ArrayAdapter,可能要重载public View getView (int position, View convertView, ViewGroup parent)方法
可以判断View convertView 是否为空,以此觉得重新加载还是不加载,优化性能。

API
java.lang.Object
↳ android.widget.BaseAdapter

↳ android.widget.ArrayAdapter
public View getDropDownView (int position, View convertView, ViewGroup parent)

Added in API level 1
Get a View that displays in the drop down popup the data at the specified position in the data set.

Parameters
position index of the item whose view we want.
convertView the old view to reuse, if possible. Note: You should check that this view is non-null and of an appropriate type before using. If it is not possible to convert this view to display the correct data, this method can create a new view.
parent the parent that this view will eventually be attached to
Returns
a View corresponding to the data at the specified position.
public View getView (int position, View convertView, ViewGroup parent)

Added in API level 1

开发项目小技巧

Tips
Ecplise中暂时不用的项目,右键项目“Close Project”,减少程序卡顿情况。

Ecplise输入“syso”,再按 Alt+/ 可以快速加入System.out.println();

更多相关文章

  1. Android Studio高级控件(自动提示文本框)
  2. Android 分页控件制成底部菜单.
  3. android 控件学习---------GridView
  4. Android 控件之Gallery和ImageSwitcher图片切换器
  5. 赵雅智_名片夹(4)_Android中listview可折叠伸缩仿手风琴效果(静态)
  6. Android中常常使用shape来定义控件
  7. 关于解决为什么设置控件居中等位置无反应的问题
  8. android 视频、图片混合轮播控件zbanner

随机推荐

  1. Maven开发Android指南 2 配置android-mav
  2. android sdk setup时呈现:Failed to fetc
  3. android 画虚线、实线,画圆角矩形,一半圆角
  4. Android(安卓)NFC架构分析
  5. Android(安卓)侧滑菜单的实现
  6. 通过WifiManager,DhcpInfo获取android IP
  7. Android(安卓)获取状态栏的高度
  8. Android启动优化
  9. linux基础教程--安装Android(安卓)SDK
  10. android之View属性