个人理解
TextView就是一个文本,在手机虚拟机屏幕上以字幕的形式显示
EditView是编辑框,可以在框内输入内容
两者实现方法很类似以TextView详解;
EditView 格式:<EditView />
TextView格式:<TextView />
<TextView
android:id="@+id/textview"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:autoLink="all"
android:textColor="#00FF00"
android:textSize="20sp"
android:text="欢迎大家访问我的Blog,我的博客:http://blog.youkuaiyun.com/candy421458216 , 我的电话:110"
/>
详细分析下这段代码:
android:id="@+id/textview"
android:id可以定义三种id
1.android:id = "@android:id/tabhost"
这种引用,一般是android组件内部调用时使用
例如tanhost中的:mTabContent = (FrameLayout) findViewById(com.android.internal.R.id.tabcontent);
2.android:id = "@+id/IIRoot"
自己添加定义的一个id;可以在java class中引用定义的变量:R.id.IIRoot
3.android:id = "@id/IIRoot"
使用一个已经存在的ID引用
android:layout_width="wrap_content"
android:layout_height="wrap_content"
wrap_content是表示格局的一种参数,一共有三个参数:wrap_content, fill_parent, match_parent
与布局相关的还有:
android:orientation = "vertical"
android:layout_weight="1"
参数vertical表示垂直方式对齐,horizontal表示水平方式对齐; "1"也可以是其他的数字,是表示button按钮的显示比例;
android:autoLink="all"
android:textColor="#00FF00"
android:textSize="20sp"
autoLink设置是否当文本为URL链接(none/web/phone/map/all) ;
android:text="欢迎大家访问我的Blog,我的博客:http://blog.youkuaiyun.com/candy421458216 , 我的电话:110"
web设置自动识别链接,值web为匹配Web网址;
phone设置自动识别链接,值phone为匹配电话号码;
email设置自动识别链接,值email为匹配Email地址;
all设置自动识别链接,值all为匹配所有;
textColor为文本的颜色显示,textSize为文字大小;text内容则是在屏幕上显示的文本;