Android Studio-02【使用Layout Editor建立使用者介面 use the Layout Editor build a UI】

 1.  設置工作區 Set up your workspace

     app  res  layout  activity_main.xml.


     Click Select Design Surface  Select Blueprint

     Click View Options  Select Show All Constraints   

     Click Default Margins  Select 16

     Click Device for Preview  Select your device



 2.  加入文字及按鈕 Add a text box and a button

     Click TextView in the Component Tree panel  Press the Delete key

     Drag Plain Text  

     Drag button  

     Click Select Design Surface  Select Design

 3.  變更文字串內容 Change the UI strings

     app  res  values  strings.xml.


     Click Open editor (opens the Translations Editor Click Add Key
  • Add Key 1:  
    • Key: "edit_message"
    • Default Value: "Enter a message"
  • Add Key 2:  
    • Key: "button_send"
    • Default Value: "Send"


     Click activity_main.xml   Click Attributes window
  •  text box:  
    • text property: Delete the value
    • hint property: Click Pick a Resource. Double-click edit_message
  •  button:  
    • text property: Delete the value
    • hint property: Click Pick a Resource. Double-click button_send



 4.  Run the app on an emulator(AVD). Successfully!




留言