关于制作习惯养成打卡仿uhabit的app

由于是刚接触android studio 开发,就选择了一个比较简单的uhabit开源软件,我写的跟开源软件里面的代码有很大的不同,但设计的功能,我是努力想做的跟uhabit相似的。但是最后还有好多没有完成。

在写的过程中遇到了很多问题

1.首先是对于一些文件的使用,比如style文件,是自己要添加东西进去然后供自己调用的,@style。。。之类的。

2.对于一些布局,当时没有好好看,在设计界面的时候吃亏了,比如LinearLayout是线性布局,所以对于android:layout_above之类的摆放位置的就不能用了,还有一点不同的是,因为在网上百度demo的时候,一直看到的是<RealitiveLayout,所以可以用

android :layout_above=",但是自己添加一个layout文件时系统自动定义的

<android.support.constraint.ConstraintLayout

这种情况下,就是用

app:layout_constraintTop_toBottomOf="@+id/edit_text1"形式。

3.对于设计一个好看的button,一直想把button变成没有棱角的,还有自定义的图片。

首先是设置一个imageButton

<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:tools="http://schemas.android.com/tools"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    tools:context="com.example.jm.demo.register" >

    <TextView
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_margin="50dip"
        android:text="hello_world"
        android:paddingTop="20dp"
        android:paddingRight="20dp"
        android:paddingLeft="20dp"
        android:paddingBottom="20dp"
        android:background="@drawable/shape_world"/>

</RelativeLayout>

效果图

 

其中的shape_world帮我实现了我想要的很多东西,比如背景,还有一个比较圆的button。

shape_worid是写在drawable下面的一个文件

<?xml version="1.0" encoding="utf-8"?>

<layer-list xmlns:android="http://schemas.android.com/apk/res/android" >

    <item>
        <shape
            android:padding="10dp"
            android:shape="rectangle" >

            <!-- 实心 -->
            <solid android:color="#2e1f80" />
            <!-- 圆角 -->
            <corners android:radius="10dip" />
            <!-- <corners android:topRightRadius="@dimen/switch_button_inside_radius" /> -->
            <!-- <corners android:bottomRightRadius="@dimen/switch_button_inside_radius" /> -->
        </shape>
    </item>
    <item android:right="10dip">
        <shape android:shape="rectangle" ></shape>
    </item>

</layer-list>

至于为什么采用layer_list好像是因为只有这样才能把我想要的效果都实现。

4.在设计跳出来的对话框的时候。

 

主要是在一个按钮里面的onclick 实现的,

我做的是自定义的对话框,所以设计到了界面的设计。

<?xml version="1.0" encoding="utf-8"?>
<android.support.constraint.ConstraintLayout
    xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:app="http://schemas.android.com/apk/res-auto"
    xmlns:tools="http://schemas.android.com/tools"
    android:layout_width="match_parent"
    android:layout_height="wrap_content">

    <TextView
        android:id="@+id/edit_text1"
        android:layout_width="300dp"
        android:layout_height="wrap_content"
        android:paddingLeft="10dp"
        android:textSize="15dp"
        android:text="习惯标题"
        android:textColor="#87d0eb"/>

    <EditText
        android:id="@+id/edit_edit1"
        android:paddingLeft="10dp"
        android:layout_width="250dp"
        android:layout_height="50dp"
        android:paddingTop="10dp"
        app:layout_constraintTop_toBottomOf="@+id/edit_text1" />

    <ImageButton
        android:layout_width="60dp"
        android:layout_height="40dp"
        android:paddingLeft="10dp"
        android:paddingRight="10dp"
        app:layout_constraintTop_toBottomOf="@+id/edit_text1"
        app:layout_constraintLeft_toRightOf="@id/edit_edit1"
        android:scaleType="fitXY"
        android:background="@drawable/edit_image_color"
        android:src="@drawable/tiaose"/>

    <TextView
        android:id="@+id/edit_text2"
        android:paddingLeft="10dp"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:textColor="#87d0eb"
        app:layout_constraintTop_toBottomOf="@id/edit_edit1"
        android:text="Question"/>

    <EditText
        android:id="@+id/edit_edit2"
        android:layout_width="match_parent"
        android:layout_height="50dp"
        android:layout_marginRight="30dp"
        app:layout_constraintTop_toBottomOf="@+id/edit_text2"
        android:hint="eg:Did you exercise today?"/>

    <TextView
        android:id="@+id/edit_text3"
        app:layout_constraintTop_toBottomOf="@id/edit_edit2"
        android:layout_width="wrap_content"
        android:layout_height="30dp"
        android:paddingTop="10dp"
        android:paddingLeft="20dp"
        android:paddingRight="10dp"
        android:text="重复" />
    <TextView
        android:id="@+id/edit_text4"
        app:layout_constraintTop_toBottomOf="@id/edit_text3"
        android:layout_width="wrap_content"
        android:layout_height="30dp"
        android:layout_marginTop="50dp"
        android:paddingTop="10dp"
        android:paddingLeft="20dp"
        android:paddingRight="10dp"
        android:text="提醒"/>
    <Spinner
        android:id="@+id/spin_chongfu"
        android:layout_width="200dp"
        android:layout_height="wrap_content"
        app:layout_constraintTop_toTopOf="@id/edit_text3"
        android:paddingTop="10dp"
        app:layout_constraintLeft_toRightOf="@id/edit_text3"
        android:paddingLeft="100dp"
        android:entries="@array/chongfu"/>
    <Spinner
        android:id="@+id/spin_tixing"
        android:layout_width="200dp"
        android:layout_height="wrap_content"
        app:layout_constraintTop_toTopOf="@id/edit_text4"
        android:paddingTop="10dp"
        app:layout_constraintLeft_toRightOf="@id/edit_text4"
        android:paddingLeft="100dp"
        android:entries="@array/tixing"/>


</android.support.constraint.ConstraintLayout>

这是界面

 case R.id.chuangjian:
                AlertDialog.Builder builder = new AlertDialog.Builder(MainActivity.this);
                builder.setTitle("添加习惯");
                //加载一个布局
                View  view = LayoutInflater.from(MainActivity.this).inflate(R.layout.edit_habit_dialog,null);
                builder.setView(view);
                final EditText habit = (EditText)view.findViewById(R.id.edit_edit1);
                final EditText question = (EditText)view.findViewById(R.id.edit_edit2);
                builder.setPositiveButton("保存", new DialogInterface.OnClickListener() {
                    @Override
                   public void onClick(DialogInterface dialog, int which) {                       
                        String a=habit.getText().toString();
                        String b=question.getText().toString();
                        Habit habitSql = new Habit(a,0);
                        habitreop.Habit_insert(habitSql);
                        HabitName h2 = new HabitName(a);
                        data.add(h2);
                        Toast.makeText(MainActivity.this,"用户名:"+a+",密码:"+b,Toast.LENGTH_SHORT).show();
                    }
                });
                builder.setNegativeButton("放弃", new DialogInterface.OnClickListener()
                {
                    @Override
                    public void onClick(DialogInterface dialog, int which)
                    {

                    }
                });
                builder.create().show();
        }

这是添加对话框的主要代码,因为对话框是自带三个按钮的,一个是放弃,一个是保存,一个是取消,直接用builder.***调用就好,不用再去添加button。

在这个设计界面里面有个下拉框,spinner,在实现这个的时候,是在values里面添加了一个arrays 文件,里面定义的是下拉框的选项。

<?xml version="1.0" encoding="utf-8"?>
<resources>
    <string-array name="languages">
        <item>c语言</item>
        <item>java </item>
        <item>php</item>
        <item>xml</item>
        <item>html</item>
    </string-array>
    <string-array name="chongfu">
        <item>每天</item>
        <item>每周</item>
        <item>每周两次</item>
        <item>每周五次</item>
    </string-array>
    <string-array name="tixing">
        <item>1:20</item>
        <item>1:21 </item>
        <item>1:22</item>
        <item>1:23</item>
        <item>1:24</item>
    </string-array>


</resources>

还有一些关于listView和如何实现一个打卡签到的功能,

 

  • 0
    点赞
  • 19
    收藏
    觉得还不错? 一键收藏
  • 1
    评论
钉钉远程打软件是一款由阿里巴巴集团旗下的企业级智能办公平台钉钉开发的应用程序。它旨在提供一种方便快捷的远程打解决方案,让企业的员工可以灵活地完成工作时间的记录。 钉钉远程打软件通过与企业内部的人力资源管理系统或考勤系统进行对接,实现员工工作时间的准确记录。与传统打方式相比,钉钉远程打软件具有以下优势: 首先,钉钉远程打软件可以随时随地进行打,不受时间和地点的限制。无论员工身处何处,只需通过手机app一键打,即可完成打操作。这样不仅方便了员工,也减少了因为特殊情况无法到岗而导致的打记录不准确的问题。 其次,钉钉远程打软件具有高度的可靠性和安全性。通过多种技术手段,如GPS定位、人脸识别等,确保打记录的真实可信。而且,钉钉软件针对信息安全问题做出了严格的保护措施,保障了员工个人隐私的安全。 此外,钉钉远程打软件还支持多种打方式,如刷脸、扫码、定位等,使员工可以根据实际情况选择最适合自己的打方式。同时,钉钉软件还提供了数据分析功能,能够生成员工的工作时长、考勤情况等报表,为企业的考勤管理提供了帮助。 总之,钉钉远程打软件app为企业提供了一种便捷、可靠、安全的打解决方案,提高了员工工作的灵活性和企业的考勤管理效率。

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

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值