您的位置:首页 > 移动开发 > Android开发

android编程中的琐碎知识点汇总(2)

2012-01-06 16:25 399 查看
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);
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: