Android:一個完整app開發(fā)流程

一.給出功能文檔

二.APP架構(gòu)選擇

可選MVP,MVVM

三.APP目錄結(jié)構(gòu)設(shè)置

本app基于mvp架構(gòu)。除了mvp架構(gòu)的文件。
還包含下面的文件夾:
ui (下面根據(jù)Activity劃分)
widget (自定義dialog等)
base (BaseActivity,BaseFragment)

四.劃分Activity與Fragment

有側(cè)滑欄,tab的一般用fragment

五.分辨率適配

設(shè)置sw-360dp,sw-480dp等不同的dimension目錄,根據(jù)百分比計算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可以選擇不同的分辨率機器,水平或者垂直進行預(yù)覽


肉眼布局法

九.編譯系統(tǒng)配置

配置sdk版本
配置abi

十.圖片配置

使用藍湖進行圖片的協(xié)助。提供m,h,x,xx等不同分辨率的圖片


image.png
?著作權(quán)歸作者所有,轉(zhuǎn)載或內(nèi)容合作請聯(lián)系作者
【社區(qū)內(nèi)容提示】社區(qū)部分內(nèi)容疑似由AI輔助生成,瀏覽時請結(jié)合常識與多方信息審慎甄別。
平臺聲明:文章內(nèi)容(如有圖片或視頻亦包括在內(nèi))由作者上傳并發(fā)布,文章內(nèi)容僅代表作者本人觀點,簡書系信息發(fā)布平臺,僅提供信息存儲服務(wù)。

相關(guān)閱讀更多精彩內(nèi)容

友情鏈接更多精彩內(nèi)容