Android开发Android知识半栈工程师

Android初识--你所应知道的Android Studio操

2017-12-25  本文已影响113人  HusterYP

前言

AndroidStudio初探

导入项目

创建Android Library(AAR)

作用

创建

导入AAR

dependencies {
    compile project(":my-library-module")
}

使用模板

Basic Activity

Snackbar.make(view, "Replace with your own action", Snackbar.LENGTH_LONG)
                    .setAction("Action", null).show();

Bottom Navigation Activity(底部导航栏)

Fullscreen Activity(全屏)

mHideHandler.removeCallbacks(mHidePart2Runnable);
mHideHandler.postDelayed(mShowPart2Runnable, UI_ANIMATION_DELAY);

Login Activity(登录界面)

Master/Detail Flow(主列表与详细信息)

tools:context="com.example.yuanping.temp.templates.ItemListActivity"
tools:listitem="@layout/item_list_content"
<FrameLayout
android:id="@+id/frameLayout"
android:layout_width="match_parent"
android:layout_height="match_parent"
app:layout_behavior="@string/appbar_scrolling_view_behavior">

<include layout="@layout/item_list" />
</FrameLayout>

Navigation Drawer Activity(侧滑菜单)

Tabbed Activity(支持左右滑动)

正确添加资源文件

使用AS提供的面板拖拽控件

使用AS实现多语言

使用Image Asset Studio制作ICON

Image_Asset_Studio.png
Resources res = getResources();
Drawable drawable = res.getDrawable(R.drawable.myimage);
ImageView imageView = (ImageView) findViewById(R.id.myimageview);
imageView.setImageResource(R.drawable.myimage);

添加多密度矢量图Vector Asset Studio

改变资源文件的位置

android {
    sourceSets {
        main {
            res.srcDirs = ['resources/main']
        }
        debug {
            res.srcDirs = ['resources/debug']
        }
    }
}
android {
    sourceSets {
        main {
            res.srcDirs = ['res1', 'res2']
        }
    }
}

创建9.png图片

FireBase

Lint(代码检查工具)

使用注解

布局文件中的Tools属性

<android.support.constraint.ConstraintLayout
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
tools:context=".MainActivity" >
<ListView xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:id="@android:id/list"
android:layout_width="match_parent"
android:layout_height="match_parent"
tools:listitem="@layout/sample_list_item"
tools:listheader="@layout/sample_list_header"
tools:listfooter="@layout/sample_list_footer" />

调试

录制屏幕

adb(Android Debug Bridge)

常用命令

上一篇 下一篇

猜你喜欢

热点阅读