菜鸟学习日志3.界面控件的设置

前面两天,我们已经学会了先把Android开发运行起来,并且了解了一些关于布局的原理,现在我们需要往工程里添加一些控件

当你新建了一个的文件( File →New→Project  建立一个Application Project   名字我就以HelloWorld为例 一直 next 到组后一页 finish )

这样一个全新的应用程序就完成了 

但是现在程序只有一个简单的文档“HelloWorld”


是不是觉得很单调

这里你可以设置字体的颜色和大小

<TextView
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:textColor="#FF0000"
        android:textSize="30dip"
        android:text="@string/hello_world" />

我们还可以添加一些控件,比如说一个按钮

   <Button 
        android:id="@+id/onebutton"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:text="是的"
        android:onClick="buttonClickAction"/>

有时候我们也需要用到一些特殊的按钮

首先你需要将图片添加到res文件夹中的drawable中

然后添加控件代码

<ImageButton
        android:id="@+id/massagebutton"
        android:background="@drawable/massag" 
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"/>

 除了像按钮控件还有类的控件checkBox

<CheckBox
      android:id="@+id/mycheckbox"
      android:layout_width="fill_parent"
      android:layout_height="wrap_content"
      android:text="长得帅请打钩"/>
    

还有一种叫RadioBox,RadioBox处理外观上于CheckBox不一样外,RadioBox通常会组成一个Group,在Group中只能有一个RadioBox处于checked状态。

    <RadioGroup
      android:id="@+id/myradiogroup"
      android:orientation="vertical"
      android:layout_width="fill_parent"
      android:layout_height="wrap_content" >
        <RadioButton android:id="@+id/radio1"
            android:layout_width="fill_parent"
            android:layout_height="wrap_content"
            android:text ="凤姐" />
        <RadioButton android:id="@+id/radio2"
            android:layout_width="fill_parent"
            android:layout_height="wrap_content"
            android:text ="芙蓉姐姐" />
        <RadioButton android:id="@+id/radio3"
            android:layout_width="fill_parent"
            android:layout_height="wrap_content"
            android:text ="汤唯" />
 </RadioGroup>
效果如图



最后你还可以添加一个文本的输入控件EditText    

<EditText
      android:id="@+id/myfield"
      android:layout_width="fill_parent"
      android:layout_height="fill_parent"
      android:singleLine="false"/>


懂得控件的插入,离一个完整的应用就更近了~


  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值