RatingBar:
1、RatingBar的layout_width若是“fill_parent”,星號會超屏
2、getRating()/setRating(float)
ImageView:
1、使用setImageResources(int imageId)
ImageButton:
1、在drawable-mdpi檔案夾中建立xml檔案,指定控制項的游標事件,點擊事件等,
例:
<selector
xmlns:android="http://schemas.android.com/apk/res/android"
>
<item
android:state_focused="true"
android:state_pressed="false"
android:drawable="@drawable/p1"
/>
<item
android:state_focused="true"
android:state_pressed="true"
android:drawable="@drawable/s2"
/>
<item
android:state_focused="false"
android:state_pressed="false"
android:drawable="@drawable/s3"
/>
<item android:drawable="@drawable/icon" />
</selector>
2、ImageButton的android:background或者android:src的屬性可以指定在drawable-mdpi中的xml檔案;
3、dip 依賴於裝置的像素,px 像素,sp 設定字型
4、getResources()擷取android-os資源,使用ConstantState比較
Gallery/ImageSwitcher:
1、Gallery中放置的為多個TextView組成
2、點:擷取圖片資源:利用反射進行擷取圖片
例如:
/**
* 利用反射來擷取圖片資源
*/
Field[] fields = R.drawable.class.getDeclaredFields();
for (Field field : fields) {
int index = 0;
try {
index = field.getInt(R.drawable.class);
} catch (Exception e) {
e.printStackTrace();
}
imgResIds.add(index);
}
3、Gallery中的資料繫結,自訂一個Adapter使之繼承BaseAdapter【重點】;
4、代碼過程中ImageSwitcher要使用setFactory()方法設定ViewFactory,需要重寫makeView()方法;
Gallery中設定BaseAdapter來綁定資料;
5、Gallery和ImageSwitcher的組合應用的運行原理: