0_Anko_介绍,环境搭建,hello Anko,lmage Asset Studio(绘制图标),Android App Bundle(打包)

1_介绍


愉快的Android应用程序开发

Anko是一个Kotlin库,可以更快,更轻松地开发Android应用程序。它使您的代码清晰易读,让您忘记Android SDK for Java的粗糙边缘。
Anko由几部分组成:

  • Anko Commons:一个轻量级的库,里面包含用于意图,对话,日志记录等的帮助程序;
  • Anko Layouts:一种编写动态Android布局的快速且类型安全的方法;
  • Anko SQLite:Android SQLite的查询DSL和解析器集合;
  • Anko Coroutines:基于kotlinx.coroutines库的实用程序。

Anko github地址

2_环境搭建


1 javaSDK8
2 android studio

插件可以不用安装你也可以安装:
Translation(翻译英文插件)
Anko Support(预览布局目前支持不太好,xml翻译成Anko)

详细见视频:Anko_hello Anko

dependencies {
implementation "org.jetbrains.anko:anko:$anko_version"
}

ext.anko_version='0.10.8'

dependencies {
    // Appcompat-v7 (only Anko Commons)
    implementation "org.jetbrains.anko:anko-appcompat-v7-commons:$anko_version"

    // Appcompat-v7 (Anko Layouts)
    implementation "org.jetbrains.anko:anko-appcompat-v7:$anko_version"
    implementation "org.jetbrains.anko:anko-coroutines:$anko_version"

    // CardView-v7
    implementation "org.jetbrains.anko:anko-cardview-v7:$anko_version"

    // Design
    implementation "org.jetbrains.anko:anko-design:$anko_version"
    implementation "org.jetbrains.anko:anko-design-coroutines:$anko_version"

    // GridLayout-v7
    implementation "org.jetbrains.anko:anko-gridlayout-v7:$anko_version"

    // Percent
    implementation "org.jetbrains.anko:anko-percent:$anko_version"

    // RecyclerView-v7
    implementation "org.jetbrains.anko:anko-recyclerview-v7:$anko_version"
    implementation "org.jetbrains.anko:anko-recyclerview-v7-coroutines:$anko_version"

    // Support-v4 (only Anko Commons)
    implementation "org.jetbrains.anko:anko-support-v4-commons:$anko_version"

    // Support-v4 (Anko Layouts)
    implementation "org.jetbrains.anko:anko-support-v4:$anko_version"

    // ConstraintLayout
    implementation "org.jetbrains.anko:anko-constraint-layout:$anko_version"
}

3_hello Anko


0_Anko_介绍,环境搭建,hello Anko,lmage Asset Studio(绘制图标),Android App Bundle(打包)_第1张图片
代码.png
package com.example.jin.myapplication

import android.support.v7.app.AppCompatActivity
import android.os.Bundle
import org.jetbrains.anko.*

class MainActivity : AppCompatActivity() {

    override fun onCreate(savedInstanceState: Bundle?) {
        super.onCreate(savedInstanceState)
        verticalLayout {

            textView("hello Anko"){
                textSize =  26f
            }

        }
    }
}
0_Anko_介绍,环境搭建,hello Anko,lmage Asset Studio(绘制图标),Android App Bundle(打包)_第2张图片
Anko Support插件预览布局.png
0_Anko_介绍,环境搭建,hello Anko,lmage Asset Studio(绘制图标),Android App Bundle(打包)_第3张图片
效果.png

3.1_UI解耦分离

0_Anko_介绍,环境搭建,hello Anko,lmage Asset Studio(绘制图标),Android App Bundle(打包)_第4张图片
UI解耦分离.png
package com.example.jin.myapplication
import android.support.v7.app.AppCompatActivity
import android.os.Bundle
import org.jetbrains.anko.*

class MainActivity : AppCompatActivity() {
    override fun onCreate(savedInstanceState: Bundle?) {
        super.onCreate(savedInstanceState)
        MyActivityUI().setContentView(this)
    }
}

class MyActivityUI : AnkoComponent {
    override fun createView(ui: AnkoContext) = with(ui) {
        verticalLayout {
            textView("hello Anko"){
                textSize =  26f
            }

        }
    }
}

4_lmage Asset Studio(绘制图标)


0_Anko_介绍,环境搭建,hello Anko,lmage Asset Studio(绘制图标),Android App Bundle(打包)_第5张图片
lmage Asset Studio(绘制图标).png
lmage Asset Studio(绘制图标).gif
0_Anko_介绍,环境搭建,hello Anko,lmage Asset Studio(绘制图标),Android App Bundle(打包)_第6张图片
运行效果.PNG

5_打包


你可能感兴趣的:(0_Anko_介绍,环境搭建,hello Anko,lmage Asset Studio(绘制图标),Android App Bundle(打包))