Android番外篇——XML layout与CSS 转载
开发过Android应用的同学们都知道,Android工程-res-layout资源文件夹下存放着控制view布局的xml文件,我们可以同过getViewById(int i)方法,从XML中构造view及其子类,在这个过程当中,XML文件中的一切layout属性也将被赋予这个view。当然,我们也能够通过代码来为某一个view来设置layout,那是后话。通过对集中layout的分析和比较我发现,Android中AbsoluteLayout与CSS的绝对定位很像,TableLayout与HTML的表格定位很像,而RelativeLayout与CSS的相对定位很像。前两者都已经是老生常谈了,我重点比较一下最后一对,即RelativeLayout与CSS的相对定位(Position:relative)。先看一段XML:
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent" android:layout_height="fill_parent"
android:orientation="vertical">
<RadioGroup android:id="@+id/radioGroup"
android:layout_width="fill_parent" android:layout_height="167px"
xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="vertical">
<RadioButton android:id="@+id/Queen"
android:layout_width="wrap_content"
android:layout_height="wrap_content" android:text="@string/Queen">
</RadioButton>
<RadioButton android:id="@+id/Rook"
android:layout_width="wrap_content"
android:layout_height="wrap_content"&n
相关文档:
css
clearfix(针对火狐height:auto无效解决方案)
Firefox等符合W3C标准的浏览器中,如果有一个DIV作为外部容器,内部的DIV如果设置了float样式,则外部的容器DIV因为内部没有clear,导致不能被撑开。
例:
<div style=" border:2px solid #0CC; width:600px;" >
<div style="
wi ......
XML序列化与反序列化 整理文档
XML序列化与反序列化
// OBJECT -> XML
public static void SaveXml(string filePath, object obj) { SaveXml(filePath, obj, obj.GetType()); }
public static void SaveXml(string filePath, object obj, System.Type ty ......
对于带有表空间xmlns的xml文件的解析,用正常解析文件的方法总是失效,不起作用,无法获得元素。
下面给出两种方法解析此类文件:
1.按正常解析xml文件的方法,需要注意几点:
获取元素Element,不可使用函数:document.selectNodes("//region");
只可以先取到根元素,一级一级往下取,eg:
Element root = document.g ......
请看下面一段代码:
<HTML>
<HEAD>
<style>
#login {font-size:14px;color:blue;}//定义了一个ID
.left{FONT-SIZE=12PX;COLOR=RED;TEXT-ALIGN=CENTER;}//定义了一个类
</style>
<TITLE>中国</TITLE>
<BODY>
<DIV STYLE="FONT-SIZE=12PX;COLOR=RED;TEXT-ALIGN=RIGHT; ......