2016年11月24日
Is Android direct texture supported on imx6q?
http://www.slideshare.net/GlobalLogicUkraine/direct-access-to-open-gl-texture-memory-33606538
http://www.eoeandroid.com/thread-326092-1-1.html?_dsign=3b421428
http://stackoverflow.com/questions/22383533/memcpy-from-graphic-buffer-is-slow-in-android%E3%80%82
http://stackoverflow.com/questions/27426823/creating-a-mapped-direct-opengl-es-texture-on-android-ndk
2016年11月22日
ANDROID中的EGL擴(kuò)展
using direct textures on android
EGLImage - updating a texture without copying memory under Android
android 下使用Direct Texture
EGLImage與紋理
OpenGL ES 3.0 讓移動世界更上一層樓
Using GL_OES_EGL_image_external on Android
2016年11月19日
PBO + glReadPixels not so fast? 沒有結(jié)論,但至少知道正確姿勢
OpenGL ES3 接口文檔
Fast Pixel Transfers with Pixel Buffer Objects
Reading the OpenGL backbuffer to system memory
Faster Alternatives to glReadPixels and glTexImage2D in OpenGL ES
OpenGL系列教程之九:OpenGL像素緩沖區(qū)對象(PBO)
翻譯自一個蠻不錯的系列
OpenGL離線渲染和緩沖區(qū)對象
2016年10月23日
解決:Dialog沃粗、AlertDialog悼凑、DialogFragment等自定義布局中EditText無法彈出輸入法軟鍵盤的問題
http://www.reibang.com/p/85aa47d46065
注:DialogFragment沒有onShowListener粟矿,Dialog才有
android:windowSoftInputMode屬性詳解
http://blog.csdn.net/gaomatrix/article/details/7057032
注:軟鍵盤強(qiáng)制彈出需要這個屬性的配合
使用DialogFragment實(shí)現(xiàn)底部彈窗布局
http://www.reibang.com/p/3d045ee00880
注:核心是將Fragment所屬的Windows的
LayoutParams.gravity
值改為Gravity.BOTTOM
// 設(shè)置寬度為屏寬, 靠近屏幕底部。
Window window = dialog.getWindow();
WindowManager.LayoutParams lp = window.getAttributes();
lp.gravity = Gravity.BOTTOM; // 緊貼底部
lp.width = WindowManager.LayoutParams.MATCH_PARENT; // 寬度持平
window.setAttributes(lp);
[Android] Material 風(fēng)格的 Dialog 的使用
http://www.reibang.com/p/6caffdbcd5db
使用官方兼容包,來保證默認(rèn)dialog風(fēng)格一致,同時不丑
2016年10月10日
首先要理解Git的工作流程,最基礎(chǔ)的操作就不說了生音,重點(diǎn)在于Git的分支管理,參見《Pro Git》的第三章 Git 分支一章窒升。
如果項(xiàng)目中不幸使用的不是Git缀遍,難道就不能領(lǐng)略Git的靈活性了嗎?可以使用git svn
工具饱须,參見 Git與其他系統(tǒng)-作為客戶端的Git
還有文中沒提到的git svn
的命令:git與SVN協(xié)同的工作流程
2016年10月07日
深入理解Gradle: http://www.infoq.com/cn/articles/android-in-depth-gradle
2016年10月07日
Fresco: http://www.fresco-cn.org
TextView部分文字點(diǎn)擊事件: http://blog.csdn.net/true100/article/details/44855731
2016年09月30日
Jack (Java Android Compiler Kit)
似乎現(xiàn)在還沒有普遍用起來這個工具域醇。理論上是向后兼容的,打出來的包也能夠在低版本下運(yùn)行冤寿。
2016-09-26
Android單元測試研究與實(shí)踐
2016-09-21
ActivityThread的main方法究竟做了什么歹苦?
2016-09-20
Python格式化輸出
占位符 | 含義 |
---|---|
%x | hex 十六進(jìn)制 |
%d | dec 十進(jìn)制 |
%o | oct 八進(jìn)制 |
參考資料
Python print函數(shù)用法,print 格式化輸出
2016-09-19
統(tǒng)計(jì)類庫的方法數(shù)
Android Studio 插件
在線網(wǎng)站
參考資料
怎樣高效統(tǒng)計(jì)Android開源庫的方法數(shù)
2016-09-14
學(xué)習(xí)Cap'n proto
學(xué)習(xí)Cap'n proto
Cap'n proto 官網(wǎng)
Cap'n Proto for Java
FlatBuffers 體驗(yàn)
Google Protocol Buffer 的使用和原理
Protocol Buffers 是一種輕便高效的結(jié)構(gòu)化數(shù)據(jù)存儲格式督怜,可以用于結(jié)構(gòu)化數(shù)據(jù)串行化殴瘦,很適合做數(shù)據(jù)存儲或 RPC 數(shù)據(jù)交換格式。它可用于通訊協(xié)議号杠、數(shù)據(jù)存儲等領(lǐng)域的語言無關(guān)蚪腋、平臺無關(guān)、可擴(kuò)展的序列化結(jié)構(gòu)數(shù)據(jù)格式姨蟋。目前提供了 C++屉凯、Java、Python 三種語言的 API眼溶。
參考資料
Google Protocol Buffer 的使用和原理
Google Protocol Buffer Java教程
[譯]Protobuf 語法指南
設(shè)計(jì)一種簡化的 protocol buffer 協(xié)議
2016-09-13
動態(tài)開啟系統(tǒng)組件的方法
/**
* 批量禁用組件
* @param context 上下文
* @param components service悠砚、receiver組件的完整類名
* @return 本次是否有組件的狀態(tài)被變更
*/
public static boolean disableComponents(Context context, String[] components) {
PackageManager pm = context.getPackageManager();
boolean hasChange = false;
for (String component : components) {
ComponentName componentName = new ComponentName(context, component);
// enabled=true的時候,改為禁用
if (pm.getComponentEnabledSetting(componentName) != PackageManager.COMPONENT_ENABLED_STATE_DISABLED) {
pm.setComponentEnabledSetting(componentName, PackageManager.COMPONENT_ENABLED_STATE_DISABLED, PackageManager.DONT_KILL_APP);
hasChange = true;
LogUtils.d(TAG, "disable component: " + componentName);
}
}
return hasChange;
}
/**
* 批量禁用組件
* @param context 上下文
* @param components service、receiver組件的完整類名
* @return 本次是否有組件的狀態(tài)被變更
*/
public static boolean enableComponents(Context context, String[] components) {
PackageManager pm = context.getPackageManager();
boolean hasChange = false;
for (String component : components) {
ComponentName componentName = new ComponentName(context, component);
// enabled=false的時候,改為啟用
if (pm.getComponentEnabledSetting(componentName) != PackageManager.COMPONENT_ENABLED_STATE_ENABLED) {
pm.setComponentEnabledSetting(componentName, PackageManager.COMPONENT_ENABLED_STATE_ENABLED, PackageManager.DONT_KILL_APP);
hasChange = true;
LogUtils.d(TAG, "enable component: " + componentName);
}
}
return hasChange;
}
通過代碼動態(tài)啟用/關(guān)閉堂飞,即便應(yīng)用被殺配置也依舊生效灌旧。目測系統(tǒng)內(nèi)部維持了一個記錄表,后續(xù)研究下绰筛。
參考資料
Enable and disable a Broadcast Receiver
PackageManager
2016-09-12
Android手機(jī)如何錄制屏幕及轉(zhuǎn)GIF
Android Studio提示svn版本過舊
使用SmartSvn的時候枢泰,svn目錄被升級到了1.9格式,而Android Studio最高只支持1.8
升級本地的svn命令到1.9版本铝噩,然后修改Android Studio的配置衡蚂,如下:
Gradle根據(jù)buildType配置依賴
// build.gradle
android {
buildTypes {
...
custom {
...
}
}
}
dependencies {
customCompile fileTree(dir: 'custom/libs', include: '*.jar')
}
記得android
的block要在dependencies
前面,否則Gradle會報(bào)錯,提示找不到customCompile
這個DSL方法
2016-09-06
第三方依賴minSdkVersion高于項(xiàng)目的minSdkVersion導(dǎo)致項(xiàng)目編譯不過
在AndroidManifest.xml
內(nèi)的<use-sdk>
標(biāo)簽內(nèi)添加tools:overrideLibrary="包名"
如:
<use-sdk tools:overrideLibrary="第三方依賴的名字" />
2016-09-05
構(gòu)建服務(wù)器提示構(gòu)建腳本錯誤:$'\r': command not found
Windows下的文件格式采用\n\r
換行毛甲,Unix下采用\n
換行年叮,導(dǎo)致Linux構(gòu)建服務(wù)器上運(yùn)行腳本的時候在行開始發(fā)現(xiàn)了不支持的命令'\r'。
使用dos2unix
命令將文件的格式轉(zhuǎn)為unix格式即可丽啡。
# Usage
dos2unix build.sh
自定義shape背景透明要顯式指定color為透明
自定義shape時谋右,如果不需要底色,一般會省略<solid />
的定義补箍,在大部分系統(tǒng)上,這個時候是沒有底色的啸蜜,即透明效果坑雅。但在某些rom,如小米2A衬横,會出現(xiàn)系統(tǒng)給的默認(rèn)底色是黑色裹粤,導(dǎo)致視覺還原出問題。
<?xml version="1.0" encoding="utf-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android"
android:shape="rectangle">
<!-- 圓角 -->
<corners android:radius="1dp" />
<!-- 底色蜂林,這里要顯式指定為透明 -->
<solid android:color="@color/kg_color_transparent" />
<!-- 高度 -->
<size android:height="12dp"/>
<!-- 邊線 -->
<stroke android:width="1dp" android:color="#7d98a9" />
<!-- 內(nèi)邊距 -->
<padding android:left="2dp" android:right="2dp" />
</shape>
2016-09-02
動畫效果
xml方式定義
<animation-list android:id="@+id/selected" android:oneshot="false">
<item android:drawable="@drawable/wheel0" android:duration="50" />
<item android:drawable="@drawable/wheel1" android:duration="50" />
<item android:drawable="@drawable/wheel2" android:duration="50" />
<item android:drawable="@drawable/wheel3" android:duration="50" />
<item android:drawable="@drawable/wheel4" android:duration="50" />
<item android:drawable="@drawable/wheel5" android:duration="50" />
</animation-list>
oneshot
:true則只播放一次遥诉,false則表示聯(lián)系播放
<item>
:定義一幀動畫,屬性drawable
指定這一幀對應(yīng)的圖片噪叙,duration
指定這一幀的播放時長(ms)
代碼方式
Drawable[] loadingDrawables = new Drawable[] {
Global.getResources().getDrawable(R.id.wheel0),
Global.getResources().getDrawable(R.id.wheel1),
Global.getResources().getDrawable(R.id.wheel2),
Global.getResources().getDrawable(R.id.wheel3),
Global.getResources().getDrawable(R.id.wheel4),
Global.getResources().getDrawable(R.id.wheel5)
};
AnimationDrawable animationDrawable = new AnimationDrawable();
for (Drawable frame : loadingDrawables) {
animationDrawable.addFrame(frame, 50);
}
播放和停止
ImageView img = (ImageView)findViewById(R.id.spinning_wheel_image);
img.setBackgroundResource(R.drawable.spin_animation);
// 代碼定義的方式
// img.setBackgroundDrawable(animationDrawable);
// 獲取背景矮锈,xml定義的會編譯為AnimationDrawable 對象
AnimationDrawable frameAnimation = (AnimationDrawable) img.getBackground();
// 啟動播放,默認(rèn)是循環(huán)播放
frameAnimation.start();
// 停止播放
frame.Animation.stop();
參考資料
2016-09-01
動態(tài)加載dex文件
2.3系統(tǒng)無法直接加載dex文件睁蕾,僅支持加載zip格式的dex包苞笨,為了保證兼容,必須將dex文件改名為classes.dex
子眶,在壓縮成zip格式的壓縮包瀑凝。