开发学习-第一个Android页面

20170707
昨天在同事的讲解下,练习一点开发的技能。主要解决两个问题:
1.测试时,对UI测试的不确定性。
2.通过自己写,加深对Android的了解,增加测试面。

选择登录页面,主要是因为简单。
遇到的问题主要有:
1.布局问题
主要用到RelativeLayout 与 LinearLayout两种进行组合,嵌套。

1)其中在底部两个textview需要两端对齐时,采用了相对布局,通过设置
android:layout_alignParentRight="true"来解决对齐问题。

<RelativeLayout
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    android:layout_alignParentBottom="true"
    android:layout_marginBottom="39dp">
    <TextView
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:textColor="#FF913a"
        android:text="我要入驻"/>

    <TextView
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:textColor="#999999"
        android:layout_alignParentRight="true"
        android:text="登录出现问题?"/>
</RelativeLayout>
2)控件水平居中对齐的问题(单选按钮,同意《XXX协议部分》),通过android:layout_gravity="center_vertical"解决的。

2.解决EditText默认选中状态光标与下划线变为红色,且加粗的问题。
解决方法:去掉editText的线,添加view。
<EditText
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:textColorHint="#cccccc"
android:textSize="14sp"
android:textCursorDrawable="@null"
android:background="@null"
android:hint="输入手机号" />
<View
android:layout_width="match_parent"
android:layout_height="1px"
android:layout_marginTop="2dp"
android:background="#000000"
/>
3.实现按钮圆角
1).在drawable下,新建一个Drawable recourse file,
<?xml version="1.0" encoding="utf-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android">
android:shape="rectangle" >

<!-- 填充的颜色 -->
<solid android:color="#ffcf29" />

<!-- 设置按钮的四个角为弧形 -->
<!-- android:radius 弧形的半径 -->
<corners android:radius="5dip" />

<!-- padding:Button里面的文字与Button边界的间隔 -->
<padding
    android:bottom="10dp"
    android:left="10dp"
    android:right="10dp"
    android:top="10dp" />

</shape>
2).然后在activity_main.xml里面引用。

android:background="@drawable/button_radius"

附上已经实现的效果图,还是挺漂亮的,呵呵

Screenshot_2017-07-07-13-47-04.jpeg

当前发现的问题有:
1.在控件大小与左右间距时,总感觉用=XXdp的形式不太好,有待进一步优化。
2.UI切图时,同样功能的图标所切的尺寸不一致,比如电话与密码的图标,应该是30x30,但密码图标却切成了了23x31,应属于UI问题,需要改进。

目前只实现了UI部分,等实现逻辑部分再来更新。

最后编辑于
©著作权归作者所有,转载或内容合作请联系作者
平台声明:文章内容(如有图片或视频亦包括在内)由作者上传并发布,文章内容仅代表作者本人观点,简书系信息发布平台,仅提供信息存储服务。

推荐阅读更多精彩内容