1.控制項配置 xml中有趣的屬性:
android:background
可以通過以下兩種方法設定背景為透明:"@android:color/transparent"和"@null"。注意TextView預設是透明的,不用寫此屬性,但是Buttom/ImageButton/ImageView想透明的話就得寫這個屬性了。
android:drawingCacheQuality
設定繪圖時半透明品質。有以下值可設定:auto(預設,由架構決定)/high(高品質,使用較高的色彩深度,消耗更多的記憶體/low(低品質,使用較低的色彩深度,但是用更少的記憶體)。
android:fadingEdge
設定拉捲軸時 ,邊框漸層的放向。none(邊框顏色不變),horizontal(水平方向顏色變淡),vertical(垂直方向顏色變淡)。
android:fadingEdgeLength
設定邊框漸層的長度。
android:scrollbarDefaultDelayBeforeFade
設定N毫秒後開始淡化,以毫秒為單位。
android:scrollbarFadeDuration
設定捲軸淡出效果(從有到慢慢的變淡直至消失)時間,以毫秒為單位。Android2.2中捲軸滾動完之後會消失,再滾動又會出來,在1.5、1.6版本裡面會一直顯示著。
android:scrollbarThumbHorizontal
設定水平捲軸的drawable。
android:scrollbarThumbVertical
設定垂直捲軸的drawable.
android:scrollbarTrackHorizontal
設定水平捲軸背景(軌跡)的色drawable
android:scrollbarTrackVertical
設 置垂直捲軸背景(軌跡)的drawable注意直接設定顏色值如”android:color/white”將得出很難看的效果,甚至都不理解這個屬性 了,這裡可以參見ApiDemos裡res/drawable/scrollbar_vertical_thumb.xml和 scrollbar_vertical_track.xml,設定代碼為:android:scrollbarTrackVertical ="@drawable/scrollbar_vertical_track"
android:soundEffectsEnabled
設定點擊或觸摸時是否有聲音效果
android:visibility
設定是否顯示View。設定值:visible(預設值,顯示),invisible(不顯示,但是仍然佔用空間),gone(不顯示,不佔用空間)
2.很經典的一個layout.xml
Xml代碼
- <?xml version="1.0" encoding="utf-8"?>
- <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
- android:orientation="vertical" android:layout_width="fill_parent"
- android:padding="8px" android:background="@color/lightblue"
- android:layout_height="fill_parent" android:gravity="center_horizontal">
- <LinearLayout android:orientation="vertical"
- android:layout_width="fill_parent" android:layout_height="wrap_content">
- <TextView android:text="@string/qr_main_contents"
- android:textColor="@color/black" android:layout_width="wrap_content"
- android:layout_height="wrap_content" />
- <Spinner android:id="@+id/qr_main_contents"
- android:layout_width="wrap_content" android:layout_height="wrap_content"
- android:entries="@+array/qr_main_contents" android:prompt="@string/qr_main_contents" />
- </LinearLayout>
- <LinearLayout android:layout_width="fill_parent"
- android:layout_weight="1" android:layout_height="wrap_content"
- android:scrollbars="vertical">
- <ScrollView android:layout_width="fill_parent"
- android:layout_height="fill_parent">
- <LinearLayout android:layout_width="fill_parent"
- android:layout_height="wrap_content" android:orientation="vertical">
- <TextView android:text="@string/qr_information_name"
- android:textColor="@color/black" android:layout_width="wrap_content"
- android:layout_height="wrap_content" />
- <EditText android:id="@+id/qr_information_name"
- android:textColorHint="@color/blue" android:singleLine="true"
- android:layout_width="fill_parent" android:layout_height="wrap_content" />
- <TextView android:text="@string/qr_information_company"
- android:textColor="@color/black" android:layout_width="wrap_content"
- android:layout_height="wrap_content" />
- <EditText android:id="@+id/qr_information_company"
- android:singleLine="true" android:layout_width="fill_parent"
- android:layout_height="wrap_content" />
- <TextView android:text="@string/qr_information_phone"
- android:textColor="@color/black" android:layout_width="wrap_content"
- android:layout_height="wrap_content" />
- <EditText android:id="@+id/qr_information_phone"
- android:singleLine="true" android:layout_width="fill_parent"
- android:layout_height="wrap_content" />
- <TextView android:text="@string/qr_information_email"
- android:textColor="@color/black" android:layout_width="wrap_content"
- android:layout_height="wrap_content" />
- <EditText android:id="@+id/qr_information_email"
- android:singleLine="true" android:layout_width="fill_parent"
- android:layout_height="wrap_content" />
- </LinearLayout>
- </ScrollView>
- </LinearLayout>
- <LinearLayout android:orientation="vertical"
- android:gravity="right" android:layout_width="fill_parent"
- android:layout_height="wrap_content">
- <Button android:text="@string/qr_main_generate"
- android:layout_width="wrap_content" android:layout_height="wrap_content" />
- </LinearLayout>
- </LinearLayout>
3.去掉頁面的標題列和資訊列
this.requestWindowFeature(Window.FEATURE_NO_TITLE);//去掉標題列
this.getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN,WindowManager.LayoutParams.FLAG_FULLSCREEN);//去掉資訊列
注意,這個設定必須放在設定布局前面,不然會報錯.
setContentView(R.layout.entrancebs);