Top Tips for Android UIs

2,787 views

Published on

For more information about developing Android application for the MOTOROLA XOOM go to http://developer.motorola.com

Published in: Technology
0 Comments
1 Like
Statistics
Notes
  • Be the first to comment

No Downloads
Views
Total views
2,787
On SlideShare
0
From Embeds
0
Number of Embeds
1
Actions
Shares
0
Downloads
84
Comments
0
Likes
1
Embeds 0
No embeds

No notes for slide

Top Tips for Android UIs

  1. 1. Suzanne AlexandraAndroidMotorola Mobility UIMOTOROLA Stylized M Motorola Trademark Holdings, LLC. . . © 2011 Motorola Mobility, Inc. All rights reserved.
  2. 2. @suzalex #appsum11krdeveloper.motorola.com 1.0 2009 2 24
  3. 3. 01020304
  4. 4. 010203 , ,04 Fragment
  5. 5. ?alignParentLeft alignParentRight
  6. 6. centerHorizontal="true" <RelativeLayout>layout_alignLeft layout_alignRight
  7. 7. ( )
  8. 8. Android
  9. 9. Honeycomb
  10. 10. Notification.BuilderNotification.Builder builder = new Notification.Builder( this );AlertDialog.Builder
  11. 11. builder.setSmallIcon(R.drawable.icon) .setContentTitle(title) .setContentText(text) .setContentIntent(pintent) // Pending Intent .setLargeIcon(myBitmap);
  12. 12. setLargeIcon() setSmallIcon() setContentTitle() setContentText()
  13. 13. -RemoteViews layout = new RemoteViews( getPackageName(), R.layout.notification);layout.setTextViewText(R.id.notification_title, getString(R.string.app_name));layout.setOnClickPendingIntent(R.id.notification_button, getDialogPendingIntent("Tapped") );builder.setContent(layout);
  14. 14. private static boolean isHoneycomb = android.os.Build.VERSION.SDK_INT > 10;if (!isHoneycomb) // Activity Intentelse // Activity Intent
  15. 15. 01020304
  16. 16. . Brain RulesDr. John Medina
  17. 17. Android? ? ? ?
  18. 18. –32 MB324 KB23 MB728 KB
  19. 19. ..
  20. 20. BitmapFactory.Options options = new BitmapFactory.Options(); options.inJustDecodeBounds = false; options.inSampleSize = 4; options.inScaled = true; options.inTargetDensity = screenDensity; Bitmap bitmap = BitmapFactory.decodeResource( getResources(), R.drawable.clover, options);
  21. 21. public View getView( int position, View convertView, ViewGroup parent) { ImageView i = new ImageView(mContext); i.setImageResource(mImageIds[position]); i.setLayoutParams(new Gallery.LayoutParams( 300, 200)); i.setScaleType(ImageView.ScaleType.FIT_XY); i.setBackgroundResource( mGalleryItemBackground); return i;}
  22. 22. 010203 , ,04
  23. 23. Honeycomb Theme.Holo Theme.Holo.Light
  24. 24. <application android:icon="@drawable/icon" android:label="@string/app_name" android:hardwareAccelerated="true" > Honeycomb
  25. 25. Android<uses-sdk android:minSdkVersion="8" android:targetSdkVersion="11" />
  26. 26. Android <style … parent= "@android:style/Theme"> <style … parent= "@android:style/Theme.Holo">
  27. 27. 01020304 Fragment
  28. 28. XOOM ..
  29. 29. <item android:showAsAction="ifRoom" … > onCreateOptionsMenu()android:actionLayout onOptionsItemSelected()android:actionViewClass
  30. 30. 1 – API 11 <uses-sdk android:minSdkVersion="8" android:targetSdkVersion="11" />
  31. 31. 2 – <item android:id="@+id/favorite" android:title="@string/favorite" android:icon="@drawable/ic_menu_star" android:showAsAction="ifRoom" />
  32. 32. 3 - @Override public boolean onOptionsItemSelected(MenuItem item) { switch (item.getItemId()) { case R.id.favorite: // return true; …}
  33. 33. <style name="MyTheme" parent="android:style/Theme.Holo" > <item name="android:actionBarStyle"> @style/ActionBar</item></style><style name="ActionBar" parent="android:style/Widget.Holo.ActionBar"> <item name="android:background"> @drawable/my_background</item></style>
  34. 34. AlertDialog.BuilderXMLDialogFragment
  35. 35. Honeycomb Honeycombprivate static boolean isHoneycomb = android.os.Build.VERSION.SDK_INT > 10;if (isHoneycomb) { //} else //}
  36. 36. Fragment
  37. 37. Fragment
  38. 38. Fragment Fragment
  39. 39. Fragment
  40. 40. Fragment Activity FragmentFragment gridFrag = getFragmentManager(). findFragmentById(R.id.photogrid);Fragment photoFrag = getFragmentManager(). findFragmentById(R.id.the_frag);
  41. 41. Fragmentprivate boolean photoInline = false;photoInline = (photoFrag != null && getResources().getConfiguration().orientation == Configuration.ORIENTATION_LANDSCAPE);if (photoInline) { //} else if ( photoFrag != null) { gridFrag.getView().setVisibility(View.GONE);}
  42. 42. Fragment
  43. 43. Fragment – Fragment (1 )<set> <objectAnimator xmlns:android= http://schemas.android.com/apk/res/android android:propertyName="x" android:valueType="floatType" android:valueFrom="-1280" android:valueTo="0" android:duration="500" /></set>
  44. 44. Fragment – Fragment (2 )FragmentTransaction ft = getFragmentManager().beginTransaction();ft.setCustomAnimations( R.anim.slide_in_left, R.anim.slide_out_right );DetailsFragment newFrag = DetailsFragment.newInstance();ft.replace(R.id.details_fragment_container, newFrag, "detailFragment");ft.commit();
  45. 45. ACTION_DRAG_STARTEDACTION_DRAG_ENTERED
  46. 46. ACTION_DROPACTION_DRAG_ENDED
  47. 47. Fragment
  48. 48. startDrag() - ? – OnLongClickListener() ClipData DragShadowBuilderpublic boolean onLongClick(View v) { ClipData data = ClipData.newPlainText("foo","bar"); DragShadowBuilder shadowBuilder = new DragShadowBuilder(v); v.startDrag(data, shadowBuilder, v, 0); return true;}
  49. 49. onDrag() (OnDragListener ) onDragclass BoxDragListener implements OnDragListener { public boolean onDrag(View self, DragEvent event) { if (event.getAction() == DragEvent.ACTION_DRAG_STARTED) { // } //}
  50. 50. ?@suzalex | @motodev
  51. 51. Motorola Mobility Inc. .Copyright © 2010-2011, Motorola, Inc. All rights reserved( ). 2 . , .2 , / . Motorola, Inc. . " " ( ) . , , , , ( , , , ) , ( ) , .Apache 2.0Copyright © 2010, Android Open Source Project. All rights reserved( ).Apache , 2.0(" "); . http://www.apache.org/licenses/LICENSE-2.0 . " " . .Creative Commons 3.0 Google (http://code.google.com/policies.html) Creative Commons 3.0 (http://creativecommons.org/licenses/by/3.0/) .

×