2020/1/10

一个简易的Android 拍照功能项目:

app/bulid.gradle:

apply plugin: 'com.android.application'

android {
    compileSdkVersion 25
    buildToolsVersion "25.0.3"
    defaultConfig {
        applicationId "com.arno.testsystemcamera"
        minSdkVersion 21
        targetSdkVersion 25
        versionCode 1
        versionName "1.0"
        testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
    }
    buildTypes {
        release {
            minifyEnabled false
            proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
        }
    }
}

dependencies {
    compile fileTree(dir: 'libs', include: ['*.jar'])
    androidTestCompile('com.android.support.test.espresso:espresso-core:2.2.2', {
        exclude group: 'com.android.support', module: 'support-annotations'
    })
    compile 'com.android.support:appcompat-v7:25.3.1'
    compile 'com.android.support.constraint:constraint-layout:1.0.2'
    testCompile 'junit:junit:4.12'
}

2020/1/7 实习第二天

NavigationView实现侧滑栏

<?xml version="1.0" encoding="utf-8"?>
<android.support.v4.widget.DrawerLayout 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:id="@+id/drawer_layout"
android:layout_width="match_parent"
android:layout_height="match_parent"
    tools:context=".MainActivity">

    <include
        layout="@layout/app_bar_main"
        android:layout_width="match_parent"
        android:layout_height="match_parent" />

<android.support.design.widget.NavigationView
    android:id="@+id/nav_view"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:layout_gravity="left"
    app:headerLayout="@layout/nav_header"
    app:menu="@menu/menu"    />

</android.support.v4.widget.DrawerLayout>

ViewPager+Fragment+TableLayout 实现左右滑动与顶部栏目显示

1.最基础:继承PagerAdapter 然后在MainActivity中 显示。

public class MypagerAdapter extends PagerAdapter {
    private ArrayList<View> viewlists;
    public MypagerAdapter(){

    }
    public MypagerAdapter(ArrayList<View> viewlists){
        super();
        this.viewlists=viewlists;
    }
    @Override
    public int getCount() {
        return viewlists.size();
    }

    @Override
    public boolean isViewFromObject(@NonNull View view, @NonNull Object o) {
        return view==o;
    }

    @Override
    public Object instantiateItem(ViewGroup container, int position) {
        container.addView(viewlists.get(position));
        return viewlists.get(position);




    }

    @Override
    public void destroyItem(ViewGroup container, int position, Object object) {

        container.removeView(viewlists.get(position));
    }
}
private ArrayList<View> alist=new ArrayList<View>();
LayoutInflater li=getLayoutInflater();
alist.add(li.inflate(R.layout.view1,null,false));
alist.add(li.inflate(R.layout.view2,null,false));
alist.add(li.inflate(R.layout.view3,null,false));

madapter=new MypagerAdapter(alist);
viewPager.setAdapter(madapter);

Toolbar NavigationIcon正确的使用姿势

Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar);
setSupportActionBar(toolbar);
drawer = (DrawerLayout)findViewById(R.id.drawer_layout);
ActionBarDrawerToggle toggle = new ActionBarDrawerToggle(
this, drawer, toolbar, R.string.navigation_drawer_open, R.string.navigation_drawer_close);
drawer.setDrawerListener(toggle);
toggle.syncState();
toolbar.setNavigationIcon(R.mipmap.nav_bar_menu);