android學習筆記4

來源:互聯網
上載者:User

 

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的組合應用的運行原理:

   

 

 

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.