AppCompotv21 및 Navigation Drawer의 애니메이션 표시기
                                            
                                                
                                                
                                                
                                                
                                                
                                                 9424 단어  Android
                    
의 목적
Material Design이 된 안드로이드 5.0 Lolipop이 발표됐고, SDK도 드디어 공개돼 Material Design의 안드로이드 앱을 만들 수 있게 됐지만, 안드로이드 4.4 이하에서도 Material Design의 앱을 제공할 수 있을 것으로 생각한다.
바로 이때 애플 v21 등장 개발이 가능하지만, Google이 만든 Apps가 제공하는 Navigation Drawer 같은 ActionBar의 애니메이션 표시기를 어떻게 설치해야 할지 모르겠습니다.
이루어지다
build.gradle
응용 프로그램 항목
build.gradle의 dependencies 섹션에 V4 support library와 V7 AppComput library를 미리 추가합니다.dependencies {
    compile 'com.android.support:support-v4:21.0.0'
    compile 'com.android.support:appcompat-v7:21.0.0'
}
styles.xml
styles.xml 적용Theme.AppCompat(이번에Theme.AppCompat.Light.DarkActionBar).<?xml version="1.0" encoding="utf-8"?>
<resources>
    <style name="AppTheme" parent="Theme.AppCompat.Light.DarkActionBar">
    </style>
</resources>
activity_my.xml
Navigation Drawer를 구현하는 XML은 다음과 같습니다.
<android.support.v4.widget.DrawerLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:id="@+id/drawer_layout"
    android:layout_width="match_parent"
    android:layout_height="match_parent">
    <FrameLayout
        android:layout_width="match_parent"
        android:layout_height="match_parent">
    </FrameLayout>
    <LinearLayout
        android:layout_gravity="start"
        android:layout_width="240dp"
        android:layout_height="match_parent"
        android:background="@android:color/white">
    </LinearLayout>
</android.support.v4.widget.DrawerLayout>
MyActivity.java
마지막으로Activity를 구현하는 Java 파일은 다음과 같습니다.
package com.sample.navdrawer;
import android.content.res.Configuration;
import android.os.Bundle;
import android.support.v4.widget.DrawerLayout;
import android.support.v7.app.ActionBarActivity;
import android.support.v7.app.ActionBarDrawerToggle;
import android.view.MenuItem;
public class MyActivity extends ActionBarActivity {
    private ActionBarDrawerToggle mDrawerToggle;
    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_my);
        final DrawerLayout drawerLayout = (DrawerLayout) findViewById(R.id.drawer_layout);
        mDrawerToggle = new ActionBarDrawerToggle(this, drawerLayout, R.string.app_name, R.string.app_name);
        mDrawerToggle.setDrawerIndicatorEnabled(true);
        drawerLayout.setDrawerListener(mDrawerToggle);
        getSupportActionBar().setDisplayHomeAsUpEnabled(true);
        getSupportActionBar().setDisplayShowHomeEnabled(true);
    }
    @Override
    public boolean onOptionsItemSelected(MenuItem item) {
        return mDrawerToggle.onOptionsItemSelected(item) || super.onOptionsItemSelected(item);
    }
    @Override
    protected void onPostCreate(Bundle savedInstanceState) {
        super.onPostCreate(savedInstanceState);
        mDrawerToggle.syncState();
    }
    @Override
    public void onConfigurationChanged(Configuration newConfig) {
        super.onConfigurationChanged(newConfig);
        mDrawerToggle.onConfigurationChanged(newConfig);
    }
}
그런 것 같아요.
 
 
                Reference
이 문제에 관하여(AppCompotv21 및 Navigation Drawer의 애니메이션 표시기), 우리는 이곳에서 더 많은 자료를 발견하고 링크를 클릭하여 보았다 https://qiita.com/ryugoo/items/1180fae3953891131b92텍스트를 자유롭게 공유하거나 복사할 수 있습니다.하지만 이 문서의 URL은 참조 URL로 남겨 두십시오.
                                
                                
                                
                                
                                
                                우수한 개발자 콘텐츠 발견에 전념
                                (Collection and Share based on the CC Protocol.)