1 / 29

動手體驗 02 按鈕放大文字

動手體驗 02 按鈕放大文字. 書上頁數: P2-21~P2-31. 設計第一個具有互動 的 App. 使用圖形界面設計畫面. 最簡單的按一下時的處理方法. 資源 ID 是資源與程式的橋樑. 為什麼是 findViewById() ?. 首先先把舊專案關閉. 建立新專案. 接著設計 App 畫面. 幫 TextView 元件設定 Id 屬性. @+id/txv 表示是要新增一個 ID, 名稱是 "txv". 存檔後才會在 R.java 中產生對應的資源 ID. 加入按鈕元件. 設定按鈕的 On Click 屬性.

etoile
Télécharger la présentation

動手體驗 02 按鈕放大文字

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. 動手體驗 02按鈕放大文字 書上頁數:P2-21~P2-31

  2. 設計第一個具有互動的 App

  3. 使用圖形界面設計畫面

  4. 最簡單的按一下時的處理方法

  5. 資源 ID 是資源與程式的橋樑

  6. 為什麼是 findViewById()?

  7. 首先先把舊專案關閉

  8. 建立新專案

  9. 接著設計 App 畫面

  10. 幫 TextView 元件設定 Id 屬性 @+id/txv 表示是要新增一個 ID, 名稱是 "txv"

  11. 存檔後才會在 R.java 中產生對應的資源 ID

  12. 加入按鈕元件

  13. 設定按鈕的 On Click 屬性 記得存檔 設定 On Click 屬性就可以處理按一下的動作

  14. 開始寫程式!

  15. 這個 View 就是被按一下的元件, 此例中就是按鈕元件

  16. 排除紅色波浪警告

  17. 在程式中改變字體大小

  18. 完成程式 記得存檔

  19. 馬上來執行看看效果

  20. 按一下按鈕果然字就變大了!

  21. Android 的尺寸單位:dp 和 sp dp:Density-independent Pixels 指定元件尺寸時用 dp sp:Scale-independent Pixels 指定文字大小時用 sp setTextSize() 就是以 sp 為單位

  22. 我們已經完成了幾個關鍵工作

  23. 開始動手! 操作程序可參考書上 P2-21~P2-31

More Related