More Related Content
Similar to Androidのライブ壁紙について
Similar to Androidのライブ壁紙について (20)
Androidのライブ壁紙について
- 3. Android SDK | Android Developers
http://developer.android.com/intl/ja/sdk/index.html
SDK sample
CubeLiveWallpaper
android-sdk-windowsdocsresourcessamples
2.8 CubeLiveWallpaper - ライブ壁紙 - ソフトウェア技術ドキュメントを勝手に翻訳
ライブ壁紙のサンプルソース
http://www.techdoctranslator.com/resources/samples/
samples-index/cubelivewallpaper-index
- 5. 解像度
指定したいピクセル数を
dip(端末の解像度におけるピクセル)への変換する
2. 複数画面のサポート - ソフトウェア技術ドキュメントを勝手に翻訳
http://www.techdoctranslator.com/android/practices/screens_support#screen-independence
public class DispToPixel {
DispToPixel() {
}
public static int Convert(Context mContext, float pixel) {
// Convert the dips to pixels
final float scale = mContext.getResources().getDisplayMetrics().density;
return (int) (pixel * scale + 0.5f);
}
}
- 8. 設定の保存|SharedPreferences
public static SharedPreferences sp;
sp=getSharedPreferences(”settings”, 0);
Editor ed = sp.edit();
//背景色
ed.putInt(”bgcol”,TypographyWallpaper.bgcol);
//カラーテーマの色の値
ed.putString(”kuler”,color_sp);
//保存を実行
ed.commit();
setting.xml
感覚的にはASでいうところの
SharedObjectに似ている。
値は端末にXMLファイルとして
保存される。
- 10. 3.5.3 Drawable リソース - ソフトウェア技術ドキュメントを勝手に翻訳
http://www.techdoctranslator.com/android/guide/resources/available-resources/drawable-resource
3.5.1 アニメーションリソース - ソフトウェア技術ドキュメントを勝手に翻訳
http://www.techdoctranslator.com/android/guide/resources/available-resources/animation-resource
ビットマップ画像は解像度ごとに作成が必要。
ボタンなどの簡易なグラフィックはShapeDrawableで
表現すると解像度ごとに作らなくてよい。
形状:四角、角丸四角、丸、リング
塗り:ベタ、グラデ(線形、放射、sweep)
その他:レイヤー、クリップ、回転(45度毎)、アニメーション
難点は確認が面倒な点。(何らかのツールが必要?
設定画面のカスタマイズ
- 11. ?xml version=”1.0” encoding=”utf-8”?
layer-list
xmlns:android=”http://schemas.android.com/apk/res/android”
item
shape
android:shape=”rectangle”
padding android:left=”0dip”
android:top=”5dip” android:right=”0dip”
android:bottom=”5dip” /
solid android:color=”#00000000”/
size android:width=”32dp” android:height=”32dp” /
/shape
/item
item
....
/layer-list
Androidのdrawabl
設定画面のカスタマイズ|リソース
- 14. ?xml version=”1.0” encoding=”utf-8”?
RelativeLayout xmlns:android=”http://schemas.android.com/apk/res/android”
android:layout_width=”wrap_content” android:layout_height=”wrap_content”
android:padding=”0dip”
ImageView android:layout_width=”wrap_content”
android:layout_height=”fill_parent” android:id=”@+id/li_image”
android:layout_margin=”4dip”
/
CheckedTextView android:layout_width=”fill_parent”
android:layout_height=”wrap_content” android:id=”@+id/li_name”
android:textStyle=”bold” android:layout_toRightOf=”@+id/li_image”
android:textColor=”#ffffff”
style=”?android:attr/spinnerDropDownItemStyle”
android:singleLine=”true” android:ellipsize=”marquee”
android:checkMark=”@drawable/checkskin”
/
/RelativeLayout
ListViewをカスタマイズする | Android Techfirm Lab
http://labs.techfirm.co.jp/android/cho/751
リストの装飾|Adapter
- 15. s:List id=”staList” width=”100%” height=”100%”
dataProvider=”{staData}”
s:itemRenderer
fx:Component
s:MobileIconItemRenderer labelFunction=”labelFunc” messageField=”name”
iconField=”graphic” iconWidth=”48”
iconHeight=”48” decoratorClass=”renderers.Chevron”
fx:Script
![CDATA[
private function labelFunc(item: Object): String {
return item.callLetters + “!!”;
}
/fx:Script
/s:MobileIconItemRenderer
/fx:Component
/s:itemRenderer
/s:List
Mobile List, Scroller and Touch - Flex SDK - Adobe Open Source
http://opensource.adobe.com/wiki/display/flexsdk/Mobile+List%2C+Scroller+and+Touch
リストの装飾|Flex (Hero)
- 19. アプリをSDカードにインストールできるようにする - Tech Booster
http://techbooster.jpn.org/application/228/
manifest android:installLocation=”preferExternal”
...
/manifest
SDカードへのインストール
internalOnly :
auto :
preferExternal :
内蔵メモリへのインストールのみ許可します。
内蔵メモリ優先でインストールします。しかし内蔵メモリの容量が一杯
だった場合はSDカードへ保存されます。
SDカードを優先してインストールしますが、SDカードの容量が一杯だっ
た場合は内蔵メモリへインストールされます。
- 23. JavaのArrayは一度サイズが決められると変更することはできない
サイズが変わる場合はArrayListを使う。
var mlist:Array = [”aaaaaa”,”bbbbbb”];
mlist[2]=”cccccc”;//あとから追加可能
String[] mlist ={ ”aaaaaa”,”bbbbbb”};
mlist[2]=”cccccc”;//エラー
ArrayListString mlist = new ArrayList();
mlist.add(”aaaaaa”);
mlist.add(”bbbbbb”);
ArrayListString mlist = new ArrayList();
mlist.add(0,”aaaaaa”);
mlist.add(1,”bbbbbb”);
ASのArray
or
JavaのArray
パフォーマンスTips|配列の生成
- 24. //サイズを固定する500個までOK
ArrayListString mlist = new ArrayList(500);
mlist[500];//エラー 501個目
ArrayListのコンストラクタに
初期容量を指定することで要素の追加処理を高速化 - Yukun’s Blog
http://www.yukun.info/blog/2008/03/arraylist-capacity.html
パフォーマンスTips|配列の生成
- 25. import java.util.Random;
private static Random rand = new Random();
public static int random(int n) {
return (rand.nextInt() 0x7FFFFFFF) % n;
}
Randomクラス
So Cool! iAppli Lecture - NextBM
http://nextbm.web.fc2.com/200808/files/doc/koza/iappli/iappli.htm
パフォーマンスTips|ランダム
- 26. public class Test extends AsyncTaskString, Void, String {
private Activity activity;
private ProgressDialog progressDialog = null;
private String responseBody;
public Test(Activity activity) {
this.activity = activity;
}
@Override
protected String doInBackground(String... params) {
// バックグラウンドで実行
//例)XMLのパースなど
return null;
}
@Override
protected void onPreExecute() {
// バックグラウンドの処理前に実行
//例)進行中ダイアログを表示
progressDialog = new ProgressDialog(activity);
progressDialog.setMessage(
activity.getResources().getText(
R.string.loading));
progressDialog.setIndeterminate(true);
progressDialog.show();
}
@Override
protected void onPostExecute(String result) {
//処理が終了されたら実行
// 進行中ダイアログをクローズ
progressDialog.dismiss();
}
}
AsyncTaskでユーザビリティを向上させる | Android Techfirm Lab
http://labs.techfirm.co.jp/android/cho/1079
パフォーマンスTips|AsyncTask(非同期処理)
- 27. public class ViewHolder {
View base;
ImageView icon = null;
ViewHolder(View base) {
this.base = base;
}
...
ImageView getIcon() {
if (icon == null) {
//参照がない場合のみ実行
icon = (ImageView) base.findViewById(R.id.li_image);
}
return icon;
}
}
Adapterの高速化 | Android Techfirm Lab
http://labs.techfirm.co.jp/android/cho/2161
パフォーマンスTips|ViewHolder