2013年8月20日 星期二

layout

for layout_height & layout_width:
match_parent & wrap_content

relative layout:

http://developer.android.com/reference/android/widget/RelativeLayout.LayoutParams.html

 it also allows you to create overlapping views and views that appear to float on top of others.


ex:

android:layout_centerHorizontal="true" 

android:layout_toRightOf="@+id/addPeriodStartDateTitleImageView"



linear layout :
延著水平或垂直排列

android:orientation="horizontal"

android:orientation="vertical"



ex:


 <LinearLayout android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal" >

        <Button   android:text="add"
         android:layout_width="0px"
         android:layout_height="wrap_content"
          android:layout_weight="1"
         />
FrameLayout     
         <Button android:text="subtract"
         android:layout_width="0px"
         android:layout_height="wrap_content"
          android:layout_weight="1"
         />
       
      </LinearLayout>
說明:
一樣的weight,兩個button平分畫面 。記得width的寬度要設成0px。


FrameLayout

http://www.onlymobilepro.com/2012/05/22/android-frame-layout-for-absolute-beginner/

一層一層疊view。

java:


layoutParams.addRule(RelativeLayout.BELOW, titleTextView.getId());


RelativeLayout.LayoutParams  layoutParams =  new RelativeLayout.LayoutParams(
LayoutParams.MATCH_PARENT, LayoutParams.MATCH_PARENT);






沒有留言:

張貼留言