android闹钟开发详解总结

android也有一段时间了,之前一直在看基础,后面想想或许做一个实例出来会明白的更多;

然后弄了一个android的闹钟,也在网上找了许多闹钟的实例,在开始的时候看着都不是很明白,再加上那些实例基本没什么注释,后面也发现了一些好的简单的实力,好了.废话不多说,现在来总结一下我的android闹钟吧.

 

界面:

 

 

做一个闹钟,先要弄好布局文件:mian.xml

需要用到的控件有 Button  TextView  DigitalClock  AnalogClock

ButtonTextView就不多说了, DigitalClock是用于显示数字的时间的, AnalogClock是用于显示图表的时间,下面是main.xml的代码:

<?xmlversion="1.0"encoding="utf-8"?>

<LinearLayoutxmlns:android="http://schemas.android.com/apk/res/android"

    android:layout_width="fill_parent"

    android:layout_height="fill_parent"

    android:orientation="vertical"

    android:background="@drawable/black"

     >

 

    <AnalogClock

        android:id="@+id/analogClock"

        android:layout_width="fill_parent"

        android:layout_height="wrap_content"/>

 

    <DigitalClock

        android:gravity="center"

        android:id="@+id/dclock"

        android:layout_width="match_parent"

        android:layout_height="wrap_content"

        android:layout_x="30px"

        android:layout_y="32px"

        android:textSize="55sp"/>

 

    <LinearLayout

        xmlns:android="http://schemas.android.com/apk/res/android"

        android:layout_width="match_parent"

        android:layout_height="wrap_content"

        android:orientation="horizontal">

 

        <TextView

            android:id="@+id/textview2"

            android:layout_width="160dp"

            android:layout_height="wrap_content"

            android:gravity="right"

            android:text="起床闹钟设置为:"/>

 

        <TextView

            android:id="@+id/textview1"

            android:layout_width="match_parent"

            android:layout_height="wrap_content"

            android:gravity="center_vertical"

            android:text="@string/hello"/>

 

    </LinearLayout>

   

        <LinearLayout

        xmlns:android="http://schemas.android.com/apk/res/android"

        android:layout_width="match_parent"

        android:layout_height="wrap_content"

        android:orientation="horizontal">

 

    <Button

        android:gravity="center"

        android:layout_weight

  • 2
    点赞
  • 27
    收藏
    觉得还不错? 一键收藏
  • 2
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论 2
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值