由于是刚接触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&