67
㙼☐⦐㢨☐ UI⪰ 㠸䚐 䖐㤵 䐵 䈐⽈⫳㜄 ⫼ⷉ ⺴⫠ὤ MOTOROLA Stylized M ⦐Ḕ⏈ Motorola Trademark Holdings, LLC.㢌 ㇵ䖐 ❄⏈ ☥⦑ ㇵ䖐㢹⏼␘. ὤ䇴 ⯜☔ ㇵ䖐⏈ 䚨 ㋀㡔㨰㢌 㣄㢹⏼␘. © 2011 Motorola Mobility, Inc. All rights reserved. Suzanne Alexandra Android ὤ㍔ 㤸⓸㇠ Motorola Mobility

Top Tips for Android UIs

Embed Size (px)

DESCRIPTION

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

Citation preview

Page 1: Top Tips for Android UIs

UI

MOTOROLA Stylized M Motorola Trademark Holdings, LLC. . . © 2011 Motorola Mobility, Inc. All rights reserved.

Suzanne AlexandraAndroid Motorola Mobility

Page 2: Top Tips for Android UIs

1.0 2009 2 24

@suzalex#appsum11kr

developer.motorola.com

Page 3: Top Tips for Android UIs
Page 4: Top Tips for Android UIs

01

02

03

04

Page 5: Top Tips for Android UIs

01

02

03, ,

04

Fragment

Page 6: Top Tips for Android UIs
Page 7: Top Tips for Android UIs
Page 8: Top Tips for Android UIs
Page 9: Top Tips for Android UIs

?

alignParentLeft alignParentRight

Page 10: Top Tips for Android UIs
Page 11: Top Tips for Android UIs

centerHorizontal="true"

layout_alignLeft<RelativeLayout>layout_alignRight

Page 12: Top Tips for Android UIs
Page 13: Top Tips for Android UIs
Page 14: Top Tips for Android UIs

( )

Page 15: Top Tips for Android UIs

Android

Page 16: Top Tips for Android UIs
Page 17: Top Tips for Android UIs

Honeycomb

Page 18: Top Tips for Android UIs

Notification.Builder

Notification.Builder builder = new Notification.Builder( this );

AlertDialog.Builder

Page 19: Top Tips for Android UIs

builder.setSmallIcon(R.drawable.icon).setContentTitle(title).setContentText(text).setContentIntent(pintent) // Pending Intent.setLargeIcon(myBitmap)

;

Page 20: Top Tips for Android UIs

setSmallIcon()setLargeIcon()

setContentText()setContentTitle()

Page 21: Top Tips for Android UIs

-

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);

Page 22: Top Tips for Android UIs

private static boolean isHoneycomb =android.os.Build.VERSION.SDK_INT > 10;

if (!isHoneycomb)// Activity Intent

else// Activity Intent

Page 23: Top Tips for Android UIs

01

02

03

04

Page 24: Top Tips for Android UIs

.

Brain RulesDr. John Medina

Page 25: Top Tips for Android UIs
Page 26: Top Tips for Android UIs
Page 27: Top Tips for Android UIs

Android?

??

?

Page 28: Top Tips for Android UIs

32 MB 324 KB

23 MB 728 KB

Page 29: Top Tips for Android UIs

.

.

Page 30: Top Tips for Android UIs

BitmapFactory.Options options = newBitmapFactory.Options();

options.inJustDecodeBounds = false;options.inSampleSize = 4;options.inScaled = true;options.inTargetDensity = screenDensity;

Bitmap bitmap = BitmapFactory.decodeResource(

getResources(),R.drawable.clover, options);

Page 31: Top Tips for Android UIs
Page 32: Top Tips for Android UIs
Page 33: Top Tips for Android UIs

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;}

Page 34: Top Tips for Android UIs

01

02

03, ,

04

Page 35: Top Tips for Android UIs
Page 36: Top Tips for Android UIs

Theme.Holo

Theme.Holo.Light

Honeycomb

Page 37: Top Tips for Android UIs

<application android:icon="@drawable/icon"

android:label="@string/app_name"

android:hardwareAccelerated="true" >

Honeycomb

Page 38: Top Tips for Android UIs

Android

<uses-sdk android:minSdkVersion="8"android:targetSdkVersion="11" />

Page 39: Top Tips for Android UIs

Android

<style … parent="@android:style/Theme.Holo">

<style … parent="@android:style/Theme">

Page 40: Top Tips for Android UIs

01

02

03

04

Fragment

Page 41: Top Tips for Android UIs
Page 42: Top Tips for Android UIs

XOOM ..

Page 43: Top Tips for Android UIs

onCreateOptionsMenu()

<item android:showAsAction="ifRoom" … >

onOptionsItemSelected()android:actionLayoutandroid:actionViewClass

Page 44: Top Tips for Android UIs

1 – API 11

<uses-sdk android:minSdkVersion="8"android:targetSdkVersion="11" />

Page 45: Top Tips for Android UIs

2 –

<item android:id="@+id/favorite"android:title="@string/favorite" android:icon="@drawable/ic_menu_star" android:showAsAction="ifRoom" />

Page 46: Top Tips for Android UIs

3 -

@Overridepublic boolean onOptionsItemSelected(MenuItem item) {

switch (item.getItemId()) {case R.id.favorite:

// return true;

…}

Page 47: Top Tips for Android UIs

<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>

Page 48: Top Tips for Android UIs

AlertDialog.Builder

XML

DialogFragment

Page 49: Top Tips for Android UIs

Honeycomb Honeycomb

private static boolean isHoneycomb =android.os.Build.VERSION.SDK_INT > 10;

if (isHoneycomb) {//

} else//

}

Page 50: Top Tips for Android UIs

Fragment

Page 51: Top Tips for Android UIs

Fragment

Page 52: Top Tips for Android UIs

FragmentFragment

Page 53: Top Tips for Android UIs

Fragment

Page 54: Top Tips for Android UIs

FragmentActivity Fragment

Fragment gridFrag =getFragmentManager().findFragmentById(R.id.photogrid);

Fragment photoFrag = getFragmentManager().findFragmentById(R.id.the_frag);

Page 55: Top Tips for Android UIs

Fragment

private boolean photoInline = false;

photoInline = (photoFrag != null && getResources().getConfiguration().orientation== Configuration.ORIENTATION_LANDSCAPE);

if (photoInline) {//

} else if ( photoFrag != null) {gridFrag.getView().setVisibility(View.GONE);

}

Page 56: Top Tips for Android UIs

Fragment

Page 57: Top Tips for Android UIs

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>

Page 58: Top Tips for Android UIs

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();

Page 59: Top Tips for Android UIs
Page 60: Top Tips for Android UIs

ACTION_DRAG_STARTED

ACTION_DRAG_ENTERED

Page 61: Top Tips for Android UIs

ACTION_DROPACTION_DRAG_ENDED

Page 62: Top Tips for Android UIs

Fragment

Page 63: Top Tips for Android UIs

- ?– OnLongClickListener()

ClipData DragShadowBuilder

startDrag()

public boolean onLongClick(View v) {ClipData data = ClipData.newPlainText("foo","bar");DragShadowBuilder shadowBuilder = new DragShadowBuilder(v);v.startDrag(data, shadowBuilder, v, 0);return true;}

Page 64: Top Tips for Android UIs

(OnDragListener )onDrag

onDrag()

class BoxDragListener implements OnDragListener {

public boolean onDrag(View self, DragEvent event) {if (event.getAction() ==

DragEvent.ACTION_DRAG_STARTED) {//

} //

}

Page 65: Top Tips for Android UIs

?@suzalex | @motodev

Page 66: Top Tips for Android UIs
Page 67: Top Tips for Android UIs

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/) .