加入收藏 | 设为首页 | 会员中心 | 我要投稿 济南站长网 (https://www.0531zz.com/)- 科技、建站、经验、云计算、5G、大数据,站长网!
当前位置: 首页 > 教程 > 正文

Android模拟打电话程序达成

发布时间:2021-11-24 19:13:19 所属栏目:教程 来源:互联网
导读:首先建一个新项目叫Myphone 1、界面设计很简单 打开main.xml文件编辑添一个编译文本框和一个按钮代码如下: ?xml version=1.0 encoding=utf-8? LinearLayout xmlns:Android=http://schemas.android.com/apk/res/android android:layout_width=fill_parent and
首先建一个新项目叫Myphone
 
1、界面设计很简单
 
打开main.xml文件编辑添一个编译文本框和一个按钮代码如下:
 
<?xml version="1.0" encoding="utf-8"?>  
<LinearLayout xmlns:Android="http://schemas.android.com/apk/res/android"  
    android:layout_width="fill_parent"  
    android:layout_height="fill_parent"  
    android:orientation="vertical" >  
  
    <TextView  
        android:layout_width="fill_parent"  
        android:layout_height="wrap_content"  
        android:text="@string/phone" />  
    <EditText   
        android:layout_width="fill_parent"  
        android:layout_height="wrap_content"  
        android:id="@+id/text"  
        />  
    <Button   
        android:layout_width="wrap_content"  
        android:layout_height="wrap_content"  
        android:id="@+id/button"  
        android:text="@string/button"  
        />  
</LinearLayout>  
上文件的TextView是一个类似java中的label标签,相当于html中的input控件,用以输入的视图控件!EditText类似于java中的文本框,可编辑的文本框,输入内容!Button就是一个按钮!
代码 :
<?xml version="1.0" encoding="utf-8"?>
XML (Extensible Markup Language) 是一种标记描述语言,不管是语法还是看起来的样子,都相当类似网页所使用的 HTML 标记语言。 XML 被广泛地运用在 Java 程序的设定 中 。 main.xml文件里,第一行是每个 XML 描述档固定的开头内容,用来指示这个文字档 桉是以 XML 格式描述的。
 
代码 :
<LinearLayout></LinearLayout>" 线性版面配置 "(LinearLayout) 标签,使用了两个「 LinearLayout 」标签,来表示一个界面元件的区块。后头的标签前加上一个「 / 」 符号来表示结束标签。 " 线性版面配置 " 所指的是包含在 「 LinearLayout 」标签中,所有元件的配置方式,是将一个接一个元件由上而下排队排下来的意思。
 
代码 :
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns 开头的这串叙述,是用来宣告这个 XML 描述档桉的的名称空间 (NameSpace) , 后面接的 URL( 网址 ) ,表示这个描述档桉会参照到 Android 名称空间提供的定义。 所有Android 版面配置档桉的最外层标签中,都必须包含这个属性。
 
android:layout_width定义宽度,它有fill_parent(填满整个上层元件),wrap_content值,还有自定义一下值以px(是屏幕的像素点)、in(英寸)、mm(毫米)、pt(磅1/72英寸)、dp(一个基于density的抽象单位,如果一个160dpi的屏幕,1dp=1px)、dip(等同于dp)、sp(同dp相似,但是还会根据用户的字体大小偏好来缩放);建议使用sp作为文本的单位,其它用dip!!
 
android:layout_height定义高度,同上!!
 
androd:orientation="vertical"版本走向,垂直走!!
 
android:id="@+id/text"是定义该组件的id
 
android:text="@string/button"文本是string.xml文件中定义的;

(编辑:济南站长网)

【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!

    热点阅读