2014年7月16日 星期三

基本中的基本 - UI備忘篇

-改android sdk版本 
manifest //
 <uses-sdk
        android:minSdkVersion="14"(最近改為14比較好)
        android:targetSdkVersion="19" />

-改app名字
value/ strings/ <string name="app_name">Ladybiker59</string>

-建立自己的color
value/color(+resourse)
引用 @color/mainColor
自訂法  <color name="mainColor" >#FF4444</color>

-Botton效果color
res/drawable / bg_shape (+shape)  ==>自己畫
        <gradient  
        android:angle="-45"
        android:startColor="#ED7A83"
        android:endColor="#E84B5B"
        android:type="linear"

          />
res/drawable / btn_state (+selector)
        <item 
        android:state_pressed="true"
        android:drawable="@drawable/btn_unpress_pink"
        />
    
        <item 
        android:drawable="@drawable/btn_press_blue"

        />
or
res/color(+) / button_color_state(+selector)
     <item 
          android:state_pressed="true"
          android:drawable="@color/subColor2"/> <!-- pressed -->

     <item android:color="@color/subColor3"/> <!-- default -->


-覆寫系統的樣式改為自訂的
 繼呈(parent) 系統的樣式, 再改成自己想要的內容. 
系統樣式可到 R.style / R.attr 找到來源 繼呈. 

<style name="AppBaseTheme" parent="Theme.AppCompat.Light.DarkActionBar">
        <item name="android:actionBarItemBackground">@drawable/selectable_background_example</item>  </style>

<style name= "自訂的樣式"  parent="@drawable/selectable_background_example">
      <item name= "自訂的項目">@自訂的設定</item> 
 </style>


-Leaner layout 可以用比重(weight)分配畫面配重.
要注意把height 設為"0dp" , A區設2, B區設3, 則A區=2/5 , B區=3/5. (因為畫面=2+3=5)


-action bar menu 
可以放字, 或圖.(同時給圖文, 只會出現圖.)
放字 android:title="Item 1"
放圖 android:icon="@drawable/icon1"

 showAsAction="ifRoom" ==>如果有空間就秀出來. (if超過空間, 就會放到overflow下拉選單裡)
 showAsAction="always" ==>就是要全秀出來. (if超過空間, 就會放到畫面下方)
 showAsAction="never" ==>就是不要秀出來. 


-activity 就像一個頁, fragment也是一個畫面. 
畫面轉換, 還是用  fragment比較流暢. activity間轉換會有跳轉的閃跳.
fragment畫面還可以是一個跳出來的選單. (用fragment manager去管理)


-WebView取得外部網站於app內觀看
(除了java/layout 還有manifest 要取得授權連網)
http://android-rookii.blogspot.tw/2014/07/webviewapp.html

沒有留言:

張貼留言