Android中的XML文件的作用介绍
来源:互联网 发布:linux errno 编辑:程序博客网 时间:2024/05/19 01:10
WindowManager 用法 添加View,然后移除View
WindowManager wm=(WindowManager)ChangeStatus.this.getSystemService(Context.WINDOW_SERVICE);LayoutInflater inflater=LayoutInflater.from(ChangeStatus.this);final View view=inflater.inflate(R.layout.infor_text, null);WindowManager.LayoutParams mParams = new WindowManager.LayoutParams();wm.addView(view,mParams); //添加view.findViewById(R.id.btn_infor).setOnClickListener(new OnClickListener() {@Overridepublic void onClick(View v) {// TODO Auto-generated method stubwm.removeView(view); //移除}});
当RelativeLayout 的addStatesFromChildren属性设置为true时,点击RelativeLayout 上的任意控件,RelativeLayout 都呈现被点击的效果显示
例如:
<RelativeLayout android:gravity="center_vertical" android:id="@+id/phoinix_settings_notification" android:layout_alignParentTop="true" android:layout_width="fill_parent" android:addStatesFromChildren="true" android:layout_height="wrap_content" android:background="@xml/phoinix_settings_click_bottom_style"> <TextView android:id="@+id/phoinix_settings_notificationLabel"android:layout_width="wrap_content" android:layout_height="wrap_content"android:text="@string/phoinix_settings_notificationLabel" style="@style/Label" /> <ImageButton android:id="@+id/phoinix_settings_notificationImage"android:layout_centerVertical="true"android:layout_alignParentRight="true" android:layout_marginRight="2dp"android:background="@xml/phoinix_profile_mainmenu_style" android:layout_width="wrap_content"android:layout_height="wrap_content" /> </RelativeLayout>
Android XML 各种类型文件写法:
Arrays.xml 定义数组
<resources><string-array name="proxy_types"><item>HTTP</item><item>SOCKS4</item><item>SOCKS5</item></string-array></resources>
Colors.xml
<resources><color name="blue_sky">#A0C8FF</color><color name="vert_manu">#CCFF00</color><color name="black">#000000</color><color name="white">#FFFFFF</color><color name="red">#FF0000</color><color name="link_color">#FF0066CC</color><color name="simiple_button_color">#FFF</color><color name="blue">#0000FF</color><color name="grey">#FFCBD2D8</color></resources>
在res / values目录内的任何xml档,使用<dimen>做为大小尺寸标签.
Dimens.xml 定义尺寸值
<?xml version="1.0" encoding="utf-8"?><resources><dimen name="bottom_tab_font_size">12dp</dimen><dimen name="bottom_tab_padding_up">5dp</dimen><dimen name="bottom_tab_padding_drawable">8dp</dimen></resources>
Drawables.xml
<resources> <item type="drawable" name="shader1">#7f7f7f7f</item> <item type="drawable" name="highlight">#cf7f7f7f</item> <item type="drawable" name="barbg">#ef0a4267</item> <item type="drawable" name="trans">#00000000</item> <item type="drawable" name="chatdivider">#ffd6dadc</item></resources>
Strings.xml
<resources><!-- Generic terms --><string name="app_name">Beem</string><string name="OkButton">Ok</string><string name="ClearButton">Clear</string><string name="CancelButton">Cancel</string><string name="AcceptButton">Authorize</string><string name="RefuseButton">Deny</string></resources>
Styles.xml
<resources><style name="Label"><item name="android:textSize">18sp</item><item name="android:textStyle">bold</item> <item name="android:typeface">sans</item> <!-- <item name="android:capitalize">characters</item> --><item name="android:textColor">#000000</item> <!-- #FFFFFF --> <item name="android:focusable">false</item> <item name="android:padding">12dip</item></style></resources>
phoinix_popumenu_style.xml selector选择
<selector xmlns:android="http://schemas.android.com/apk/res/android"> <item android:state_focused="true" android:state_pressed="true" android:drawable="@drawable/phoinix_pushmail_btn_selected" /> <item android:state_focused="false" android:state_pressed="true" android:drawable="@drawable/phoinix_pushmail_btn_selected" /> <item android:state_focused="true" android:drawable="@drawable/phoinix_small_selected"/></selector>
Menu
<menu xmlns:android="http://schemas.android.com/apk/res/android"><group><item android:id="@+id/chat_menu_contacts_list" android:visible="true"android:title="@string/chat_menu_contacts_list" android:icon="@drawable/ic_menu_friendslist" /><item android:id="@+id/chat_menu_change_chat" android:visible="true"android:title="@string/chat_menu_change_chat" android:icon="@drawable/ic_menu_chat_dashboard" /></group><item android:id="@+id/chat_menu_close_chat" android:visible="true"android:title="@string/chat_menu_close_chat" android:icon="@drawable/ic_menu_end_conversation" /></menu><menu xmlns:android="http://schemas.android.com/apk/res/android"><item android:id="@+id/contact_list_context_menu_chat_item"android:title="@string/CDChat"><menu></menu></item><item android:id="@+id/contact_list_context_menu_call_item"android:title="@string/CDCall" android:visible="false" /><item android:id="@+id/contact_list_context_menu_user_info"android:title="@string/CDInfos"><menu><item android:id="@+id/contact_list_context_menu_userinfo_alias"android:title="@string/userinfo_label_alias" /><item android:id="@+id/contact_list_context_menu_userinfo_group"android:title="@string/userinfo_label_chg_group" /><item android:id="@+id/contact_list_context_menu_userinfo_subscription"android:title="@string/userinfo_label_re_subscription" /><item android:id="@+id/contact_list_context_menu_userinfo_block"android:title="@string/userinfo_label_block" android:visible="false" /><item android:id="@+id/contact_list_context_menu_userinfo_delete"android:title="@string/userinfo_label_delete" /></menu></item></menu>
Drawable white_background.xml 白色圆角矩形做背景
<shape xmlns:android="http://schemas.android.com/apk/res/android" android:shape="rectangle"> <solid android:color="#FFFFFF" /> <corners android:topLeftRadius="5px" android:topRightRadius="5px" android:bottomLeftRadius="5px" android:bottomRightRadius="5px"/> <!-- <padding android:left="10dp" android:top="10dp" android:right="10dp" android:bottom="10dp" /> <stroke android:dashWidth="2dp" android:dashGap="2dp" android:width="2dp" android:color="#FF00ff00"></stroke> --> <!-- --></shape>Anim 旋转动画· <set xmlns:android="http://schemas.android.com/apk/res/android"> · · <rotate · android:interpolator="@android:anim/accelerate_decelerate_interpolator" · android:fromDegrees="0" · android:toDegrees="+360" · android:duration="3000" /> · · <!-- rotate 旋转动画效果 · 属性:interpolator 指定一个动画的插入器,用来控制动画的速度变化 · fromDegrees 属性为动画起始时物件的角度 · toDegrees 属性为动画结束时物件旋转的角度,+代表顺时针 · duration 属性为动画持续时间,以毫秒为单位 · --> · </set> <set xmlns:android="http://schemas.android.com/apk/res/android"> <rotate android:fromDegrees="0" android:toDegrees="360"android:pivotX="50%" android:pivotY="50%"android:duration="5000"android:repeatMode="restart"android:repeatCount="infinite" /></set>
XML中
alpha
渐变透明度动画效果
scale
渐变尺寸伸缩动画效果
translate
画面转换位置移动动画效果
rotate
画面转移旋转动画效果
<set xmlns:android="http://schemas.android.com/apk/res/android"> <!-- Tween Animation:通过对场景里的对象不断做图像变换(平移、缩放、旋转)产生动画效 Alpha:渐变透明度动画效果 Scale:渐变尺寸伸缩动画效果 Translate:画面转换位置移动动画效果 Rotate:画面旋转动画效果 Tween Animation 通用属性[类型] 功能 Duration[long] 属性为动画持续时间 时间以毫秒为单位 fillAfter [boolean] 当设置为true ,该动画转化在动画结束后被应用 fillBefore[boolean] 当设置为true ,该动画转化在动画开始前被应用 interpolator 指定一个动画的插入器 有一些常见的插入器 accelerate_decelerate_interpolator 加速-减速 动画插入器 accelerate_interpolator 加速-动画插入器 decelerate_interpolator 减速- 动画插入器 其他的属于特定的动画效果 repeatCount[int] 动画的重复次数 RepeatMode[int] 定义重复的行为 1:重新开始 2:plays backward startOffset[long] 动画之间的时间间隔,从上次动画停多少时间开始执行下个动画 zAdjustment[int] 定义动画的Z Order的改变 0:保持Z Order不变 1:保持在最上层 -1:保持在最下层 --> <!-- 透明控制动画 --> <alpha android:fromAlpha="0.1" android:toAlpha="1.0" android:duration="3000" /> <!-- 尺寸伸缩动画效果 scale 属性:interpolator 指定一个动画的插入器 有三种动画插入器: accelerate_decelerate_interpolator 加速-减速 动画插入器 accelerate_interpolator 加速-动画插入器 decelerate_interpolator 减速- 动画插入器 其他的属于特定的动画效果 fromXScale 属性为动画起始时 X坐标上的伸缩尺寸 toXScale 属性为动画结束时 X坐标上的伸缩尺寸 fromYScale 属性为动画起始时Y坐标上的伸缩尺寸 toYScale 属性为动画结束时Y坐标上的伸缩尺寸 说明: 以上四种属性值 0.0表示收缩到没有 1.0表示正常无伸缩 值小于1.0表示收缩 值大于1.0表示放大 pivotX 属性为动画相对于物件的X坐标的开始位置 pivotY 属性为动画相对于物件的Y坐标的开始位置 说明: 以上两个属性值 从0%-100%中取值 50%为物件的X或Y方向坐标上的中点位置 长整型值: duration 属性为动画持续时间 说明: 时间以毫秒为单位 布尔型值: fillAfter 属性 当设置为true ,该动画转化在动画结束后被应用 --> <scale android:interpolator="@android:anim/accelerate_decelerate_interpolator" android:repeatCount="1" android:fromXScale="0.5" android:fromYScale="0.5" android:toXScale="1.4" android:toYScale="1.4" android:pivotX="50%" android:pivotY="50%" android:fillAfter="false" android:duration="3000" /> <!-- 画面转换位置移动动画效果 translate fromXDelta toXDelta 为动画、结束起始时 X坐标上的位置 fromYDelta toYDelta 为动画、结束起始时 Y坐标上的位置 --> <translate android:repeatCount="2" android:fromXDelta="-30" android:fromYDelta="-30" android:toXDelta="-80" android:toYDelta="200" android:duration="3000" /> <!-- 画面转移旋转动画效果 rotate fromDegrees 为动画起始时物件的角度 说明 当角度为负数——表示逆时针旋转 当角度为正数——表示顺时针旋转 (负数from——to正数:顺时针旋转) (负数from——to负数:逆时针旋转) (正数from——to正数:顺时针旋转) (正数from——to负数:逆时针旋转) toDegrees 属性为动画结束时物件旋转的角度 可以大于360度 pivotX pivotY 为动画相对于物件的X、Y坐标的开始位 说明:以上两个属性值 从0%-100%中取值 50%为物件的X或Y方向坐标上的中点位置 --> <rotate android:interpolator="@android:anim/accelerate_interpolator" android:repeatCount="2" android:fromDegrees="0" android:toDegrees="+270" android:pivotX="50%" android:pivotY="50%" android:duration="3000" /> </set>
加入动画
Animation mAnimation ;
mAnimation = AnimationUtils.loadAnimation(this, R.anim.anim); TextView text = (TextView)findViewById(R.id.textview00); text.setAnimation(mAnimation);
转载地址:http://blog.csdn.net/chajbq99/article/details/6750204
- Android中的XML文件的作用介绍
- Android中的XML文件的作用介绍
- android中的xml文件介绍
- Android中的ids.xml的作用
- Android 中各种XML文件的作用
- Android 中各种XML文件的作用
- Android 中各种XML文件的作用
- Android 中各种XML文件的作用
- Android 中各种XML文件的作用
- Android 中各种XML文件的作用
- Android 中各种XML文件的作用
- Android 中各种XML文件的作用
- Android 中各种XML文件的作用
- Android中项目的AndroidManifest.xml文件的作用及改文件中相关属性的具体介绍
- xml文件的作用
- android的AndroidManifest.xml文件介绍
- android的AndroidManifest.xml文件介绍
- android的AndroidManifest.xml文件介绍
- android安装busybox
- loadrunner error提示: Action.c(15): Error -27796: Failed to connect to server "10.9.34.101:80":
- Linux服务器---常用端口
- ArcGIS.Server.9.3和ArcGIS API for Flex实现Query查询定位中心功能(七)
- 视图UIView的frame、bounds与center属性
- Android中的XML文件的作用介绍
- Apache Kafka系列之Kafka介绍
- 创建过图片之后一定要释放。
- nginx+tornado 504 gateway timeout
- ArcGIS.Server.9.3和ArcGIS API for Flex实现MapTips(八)
- STL 中 map 的用法
- android通过反射获取内置外置存储器列表
- 推荐两款富文本编辑器:NicEdit和Kindeditor
- void kobject_init(struct kobject *kobj, struct kobj_type *ktype)