一、布局的一些問題總結
1、首先說下RelativeLayout布局,其實實現的效果就是按照元素的相對位置設定擺放位置,如果沒有設定相關屬性,例如above、belove等相關屬性是預設是在螢幕的頂部,並且多個View互相疊放,後面的View會疊放在前面的View之上。根據這個特點,我們可以設定一下進度條之類的東東,比如下面的一個瀏覽器對話方塊,當訪問網頁是彈出對話方塊,網頁結束是將對話方塊的view設定gone即可。
<?xml version="1.0" encoding="utf-8"?><AbsoluteLayoutandroid:id="@+id/webfrm"android:layout_width="fill_parent"android:layout_height="fill_parent"android:background="@color/bgcolor"android:orientation="vertical"xmlns:android="http://schemas.android.com/apk/res/android"><WebViewandroid:id="@+id/webview1"android:layout_width="fill_parent"android:layout_height="fill_parent"></WebView><RelativeLayoutandroid:id="@+id/RelativeLayout01"android:layout_width="fill_parent"android:layout_height="fill_parent"><ProgressBarandroid:id="@+id/LoadingBar"android:indeterminate="true"android:visibility="visible"android:layout_centerInParent="true"android:minHeight="100px"android:minWidth="100px"android:layout_height="100px"android:layout_width="100px" /></RelativeLayout></AbsoluteLayout>
預覽:
2、FrameLayout的一些使用心得,之前項目中用的比較少,對她得認識也不深。
Framlayout可以用來實現多種介面的切換。在TabHost中經常用到。
<?xml version="1.0" encoding="utf-8"?><TabHost xmlns:android="http://schemas.android.com/apk/res/android" android:id="@android:id/tabhost" android:layout_width="fill_parent" android:layout_height="fill_parent"> <LinearLayout android:orientation="vertical" android:layout_width="fill_parent" android:layout_height="fill_parent"> <TabWidget android:id="@android:id/tabs" android:layout_width="fill_parent" android:layout_height="wrap_content" /> <FrameLayout android:id="@android:id/tabcontent" android:layout_width="fill_parent" android:layout_height="fill_parent"> <TextView android:id="@+id/textview1" android:layout_width="fill_parent" android:layout_height="fill_parent" android:text="this is a tab" /> <TextView android:id="@+id/textview2" android:layout_width="fill_parent" android:layout_height="fill_parent" android:text="this is another tab" /> <TextView android:id="@+id/textview3" android:layout_width="fill_parent" android:layout_height="fill_parent" android:text="this is a third tab" /> </FrameLayout> </LinearLayout></TabHost>
當調用到那個view是將它顯示出來即可。
二、Android 9 patch 工具的使用。
所謂 9-patch drawables,就是將一個 drawable 按照定義的 4 個邊緣的寬度大小切割成9個地區,包括4個角落,4條邊緣和一個中心地區,當把這個 drawable 繪製到一個任意矩形地區時,drawable 的各個地區有不同的展開控制(角落不展開,橫邊橫向展開,豎邊豎向展開,中心地區橫豎向都展開)。通常使用 9-patch drawable 一般是為了繪製出比較漂亮的帶圓角背景,這樣可以避免圓角及邊緣被任意展開導致變形。
說明:①左邊和頂部兩條黑線選擇展開的地區
②右邊和底部選定content,既文本地區
:
參考:http://www.cnblogs.com/qianxudetianxia/archive/2011/04/17/2017591.html
http://blog.csdn.net/xiaominghimi/article/details/6107837