Share
Embed
Transcript
42 slides
-
ࣗݾհ 4 גࣜձࣾZaim 4 AndroidΞϓϦ୲ 4 TechInstitute ୈ2ظ 4 ͪΐͬͱߨࢣ͠·ͨ͠
4 Realm meetup #2 4 ൃද > Realm with ContentProvider 2 -
ྫɿZaimͷόʔδϣϯγΣΞ 4 KitKat͕ѹతʹଟ͍ 4 ͍࣍ͰJellyBean͕ଟ͍ 4 ͜ͷ2ͭͰશମͷ 77% ΛΊΔ 4
৽نϢʔβʔͰ 88% ΛΊΔ 4 -
GOAL-1 Create a visual language that synthesizes classic principles of
good design with the innovation and possibility of technology and science. — Material design/Introduction 12 -
GOAL-2 Develop a single underlying system that allows for a
unified experience across platforms and device sizes. Mobile precepts are fundamental, but touch, voice, mouse, and keyboard are all first-class input methods. — Material design/Introduction 14 -
ஈ֊తͳMaterialDesignͷಋೖ 1. AppCompatςʔϚΛద༻͢Δ <- New! 2. ToolbarʗDrawerLayoutͳͲΛ͏ 3. ৽͍͠InterpolatorΛ͏ <-
New! 4. ඞཁʹԠͯ͡CardViewͳͲΛ͏ 19 -
StyleΛ࡞͢Δ res/values/styles.xml <!-- Base application theme. --> <style name="AppTheme" parent="Theme.AppCompat.Light.NoActionBar">
<!-- ϒϥϯυΧϥʔͷઃఆ --> <item name="colorPrimary">@color/brand_color</item> <item name="colorPrimaryDark">@color/brand_dark_color</item> <item name="colorAccent">@color/brand_accent_color</item> </style> 21 -
AppCompatActivityΛ͏ public class MainActivity extends AppCompatActivity { @Override protected void
onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_main); ... 22 -
UI Component͕ஔ ͖ΘΔ AlertDialog AppCompatButton AppCompatCheckBox AppCompatRadioButton AppCompatRatingBar AppCompatTextView AppCompatEditText
AppCompatSpinner SearchView etc... 23 -
AppCompatButton android.support.v7.widget.AppCompatButton // ϢʔβʔิॿͷΠϕϯτॲཧ public void onInitializeAccessibilityEvent(AccessibilityEvent event); // Ϣʔβʔิॿใͷॲཧ
public void onInitializeAccessibilityNodeInfo(AccessibilityNodeInfo info); //େจࣈͷஔ͖͑ON/OFF public void setAllCaps(boolean allCaps); //ςΩετͷ֤ଐੑΛηοτ public void setTextAppearance(Context context, int resId); 24 -
AppCompatCheckBox android.support.v7.widget.AppCompatCheckBox // ࠨଆͷύσΟϯάΛऔಘʢDrawable͕͋Εͦͷ༨നʣ public int getCompoundPaddingLeft(); // Ϙλϯͷը૾ΛϦιʔε͔Βηοτ public
void setButtonDrawable(int resId); // ্هͷDrawableܕ public void setButtonDrawable(Drawable buttonDrawable); 25 -
AppCompatRadioButton android.support.v7.widget.AppCompatRadioButton // ࠨଆͷύσΟϯάΛऔಘʢDrawable͕͋Εͦͷ༨നʣ public int getCompoundPaddingLeft(); // Ϙλϯͷը૾ΛϦιʔε͔Βηοτ public
void setButtonDrawable(int resId); // ্هͷDrawableܕ public void setButtonDrawable(Drawable buttonDrawable); 26 -
AppCompatTextView android.support.v7.widget.AppCompatTextView //େจࣈͷஔ͖͑ON/OFF public void setAllCaps(boolean allCaps); //ςΩετͷ֤ଐੑΛηοτ public void
setTextAppearance(Context context, int resId); 27 -
AlertDialog android.support.v7.AlertDialog // μΠΞϩάͷϘλϯΛऔಘ public Button getButton(int which); // ϘλϯΛλοϓͨ͠ͱ͖ͷϦεφʔΛηοτ
public void setButton(int which, CharSequence text, OnClickListener listener); // ϘλϯΛλοϓͨ͠ͱ͖ʹૹΔϝοηʔδΛηοτ public void setButton(int which, CharSequence text, Message message); // पғͷ༨നΛࢦఆ͠ͳ͕ΒViewΛηοτ public void setView(View view, int spacingLeft, int spacingTop, int spacingRight, int spacingBottom); etc... 29 -
Toolbar android.support.v7.widget.Toolbar Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar); // ैདྷͷActionBar૬ͷػೳΛηοτ setSupportActionBar(toolbar);
<android.support.v7.widget.Toolbar android:id="@+id/toolbar" android:layout_width="match_parent" android:layout_height="wrap_content" android:minHeight="?attr/actionBarSize" android:background="?attr/colorPrimary" android:theme="@style/ThemeOverlay.AppCompat.Dark.ActionBar" /> 31 -
DrawerLayout android.support.v4.widget.DrawerLayout <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"> <!-- ϝΠϯͷViewGroup -->
<RelativeLayout ... /> <!-- ϝχϡʔͷViewGroup --> <RelativeLayout android:layout_gravity="start" ... /> </android.support.v4.widget.DrawerLayout> 32 -
DrawerLayoutͷηοτΞοϓ-1 public class MainActivity extends AppCompatActivity { private DrawerLayout mDrawerLayout;
private ActionBarDrawerToggle mDrawerToggle; @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_main); ... // ToolbarͷηοτͳͲ mDrawerLayout = (DrawerLayout) findViewById(R.id.drawer_layout); // ActionBarDrawerToggleΛ͏ͱ৽͍͠τάϧϘλϯʹͳΔ mDrawerToggle = new ActionBarDrawerToggle(this, mDrawerLayout, R.string.app_name, R.string.app_name); mDrawerToggle.setDrawerIndicatorEnabled(true); mDrawerLayout.setDrawerListener(mDrawerToggle); getSupportActionBar().setDisplayHomeAsUpEnabled(true); getSupportActionBar().setDisplayShowHomeEnabled(true); 33 -
DrawerLayoutͷηοτΞοϓ-2 @Override public boolean onOptionsItemSelected(MenuItem item) { ... // ௨ৗͷϝχϡʔॲཧ
return mDrawerToggle.onOptionsItemSelected(item) || super.onOptionsItemSelected(item); } @Override protected void onPostCreate(Bundle savedInstanceState) { super.onPostCreate(savedInstanceState); mDrawerToggle.syncState(); } 34 -
DrawerLayoutͷηοτΞοϓ-3 ListView listView = (ListView) findViewById(R.id.listView); // ΞΧϯτใͷ෦ View headerView
= LayoutInflater.from(this) .inflate(R.layout.header_navigation_list, listView, false); listView.addHeaderView(headerView); // ϝχϡʔϦετͷ෦ ArrayAdapter<String> adapter = new ArrayAdapter<>(this, android.R.layout.simple_list_item_1, new String[]{"list1", "list2", "list3"}); listView.setAdapter(adapter); 35 -
StatusBarͷ৭Λม͑ΔʢKitKat onlyʣ <style name="AppTheme" parent="Theme.AppCompat.Light.NoActionBar"> ... <!-- StatusBarΛಁա(API Level 19Ҏ߱ͰՄೳ)
--> <item name="android:windowTranslucentStatus">true</item> </style> <!-- StatusBarɺ্ʹ24dpͣΕΔͷͰύσΟϯάΛೖΕΔ --> <android.support.v7.widget.Toolbar ... android:paddingTop="24dp" ... /> <!-- ٖࣅతͳPrimaryDark৭ͷྖҬΛషΔ --> <View android:layout_width="match_parent" android:layout_height="24dp" android:background="@color/brand_dark_color" /> 36 -
ը໘શମΛΞϓϦ ͷงғؾʹ1 4 PrimaryColor 4 PrimaryDarkColor 4 AccentColor 1 http://www.google.com/design/spec/style/
color.html#color-ui-color-application 37 -
4. ҎԼඞཁʹԠͯ͡͏ GoogleͷSampleCodeͰɺͦΕͧΕϕʔγοΫ ͳ࣮Λ֬ೝͰ͖·͢ɻ AndroidStudioͰ File > Import Sample... Ͱ։͚·͢ɻ
4 FloatingActionBar 4 CardView 4 RecyclerView 40 -
·ͱΊ 1. Android4.xͰSupportLibraryΛத৺ʹ 2. ϒϥϯυΧϥʔɺ͖ͪΜͱݕ౼ʗઃఆ͢Δ 3. Google I/Oʹ͢Δ 4 Կͳ͍͔͠Εͳ͍͚Ͳ...
※ ηογϣϯͰ༻ͨ͠ಈըΛҎԼͰެ։ͯ͠ ͓Γ·͢ɻ http://goo.gl/EEax7D 41