Android开发经验谈Android技术知识Android开发

Android:一个完整app开发流程

2019-08-29  本文已影响0人  我在等你回复可你没回

一.给出功能文档

二.APP架构选择

可选MVP,MVVM

三.APP目录结构设置

本app基于mvp架构。除了mvp架构的文件。
还包含下面的文件夹:
ui (下面根据Activity划分)
widget (自定义dialog等)
base (BaseActivity,BaseFragment)

四.划分Activity与Fragment

有侧滑栏,tab的一般用fragment

五.分辨率适配

设置sw-360dp,sw-480dp等不同的dimension目录,根据百分比计算dp值。


image.png

六.三方库使用

bindview使用butterknife,不同组件通信使用EventBus,定时使用RxJava,崩溃收集bugly

七.自定义view

按钮样式:
使用selector

<?xml version="1.0" encoding="utf-8"?>
<selector xmlns:android="http://schemas.android.com/apk/res/android">
    <item android:state_pressed="true" android:drawable="@mipmap/ic_button_b_pressed"/>
    <item android:drawable="@mipmap/ic_button_b_normal"/>
</selector>

按钮背景色,包括颜色和圆角

<?xml version="1.0" encoding="utf-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android"
    android:shape="rectangle">
    <solid android:color="#ff9ca4b1" />
    <corners android:topLeftRadius="@dimen/dp_12_dp" android:topRightRadius="@dimen/dp_12_dp" android:bottomLeftRadius="@dimen/dp_12_dp" android:bottomRightRadius="@dimen/dp_12_dp" />
</shape>

八.布局方式

使用ConstraintLayout,直接使用标注的值来做,最简单,不要用百分比。使用layout_constraint,layout_margin完成所有布局。

<?xml version="1.0" encoding="utf-8"?>
<androidx.constraintlayout.widget.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:paddingBottom="@dimen/dp_24_dp"
    android:layout_height="wrap_content"
    android:background="@drawable/base_bg_dialog1">

    <TextView
        android:id="@+id/textView"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_marginStart="8dp"
        android:layout_marginTop="@dimen/dp_24_dp"
        android:layout_marginEnd="8dp"
        android:text="@string/tip"

        android:textSize="@dimen/sp_20_sp"
        app:layout_constraintEnd_toEndOf="parent"
        app:layout_constraintStart_toStartOf="parent"
        app:layout_constraintTop_toTopOf="parent" />


    <TextView
        android:id="@+id/tv_content"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_marginStart="8dp"
        android:layout_marginTop="@dimen/dp_24_dp"
        android:layout_marginEnd="8dp"
        android:layout_marginBottom="@dimen/dp_24_dp"

        android:textSize="@dimen/sp_19_sp"
        app:layout_constraintEnd_toEndOf="parent"
        app:layout_constraintStart_toStartOf="parent"
        app:layout_constraintTop_toBottomOf="@+id/textView" />

    <TextView
        android:id="@+id/tv_cancel"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_marginTop="@dimen/dp_24_dp"
        android:layout_marginRight="@dimen/dp_60_dp"
        android:padding="@dimen/dp_10_dp"
        android:text="@string/cancel"

        android:background="@drawable/bg_text_button2"
        android:textSize="@dimen/sp_19_sp"
        app:layout_constraintBottom_toBottomOf="parent"
        app:layout_constraintEnd_toStartOf="@+id/tv_sure"
        app:layout_constraintHorizontal_bias="0.5"
        app:layout_constraintHorizontal_chainStyle="packed"
        app:layout_constraintStart_toStartOf="parent"
        app:layout_constraintTop_toBottomOf="@+id/tv_content" />


    <TextView
        android:id="@+id/tv_sure"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_marginTop="@dimen/dp_24_dp"
        android:padding="@dimen/dp_10_dp"
        android:text="@string/sure"

        android:textSize="@dimen/sp_19_sp"
        android:background="@drawable/bg_text_button2"
        app:layout_constraintBottom_toBottomOf="parent"
        app:layout_constraintEnd_toEndOf="parent"
        app:layout_constraintHorizontal_bias="0.5"
        app:layout_constraintStart_toEndOf="@+id/tv_cancel"
        app:layout_constraintTop_toBottomOf="@+id/tv_content" />

</androidx.constraintlayout.widget.ConstraintLayout>

在AndroidStudio直接肉眼布局,Android可以选择不同的分辨率机器,水平或者垂直进行预览


肉眼布局法

九.编译系统配置

配置sdk版本
配置abi

十.图片配置

使用蓝湖进行图片的协助。提供m,h,x,xx等不同分辨率的图片


image.png
上一篇下一篇

猜你喜欢

热点阅读