Update ApiDemos for ActionBar

- use Gravity.START and Gravity.END

Change-Id: Id2adac4c23ad2de2d04a36ef8195367aea63c66f
This commit is contained in:
Fabrice Di Meglio
2012-07-13 18:00:01 -07:00
parent 25fc64f00a
commit 161859ee84
2 changed files with 9 additions and 8 deletions

View File

@@ -36,7 +36,7 @@
<!-- For android.media.audiofx.Visualizer --> <!-- For android.media.audiofx.Visualizer -->
<uses-permission android:name="android.permission.RECORD_AUDIO" /> <uses-permission android:name="android.permission.RECORD_AUDIO" />
<uses-sdk android:minSdkVersion="4" android:targetSdkVersion="14" /> <uses-sdk android:minSdkVersion="4" android:targetSdkVersion="16" />
<!-- We will request access to the camera, saying we require a camera <!-- We will request access to the camera, saying we require a camera
of some sort but not one with autofocus capability. --> of some sort but not one with autofocus capability. -->
@@ -47,7 +47,8 @@
<application android:name="ApiDemosApplication" <application android:name="ApiDemosApplication"
android:label="@string/activity_sample_code" android:label="@string/activity_sample_code"
android:icon="@drawable/app_sample_code" android:icon="@drawable/app_sample_code"
android:hardwareAccelerated="true"> android:hardwareAccelerated="true"
android:supportsRtl="true">
<!-- This is how we can request a library but still allow the app <!-- This is how we can request a library but still allow the app
to be installed if it doesn't exist. --> to be installed if it doesn't exist. -->

View File

@@ -93,18 +93,18 @@ public class ActionBarDisplayOptions extends Activity
case R.id.cycle_custom_gravity: case R.id.cycle_custom_gravity:
ActionBar.LayoutParams lp = (ActionBar.LayoutParams) mCustomView.getLayoutParams(); ActionBar.LayoutParams lp = (ActionBar.LayoutParams) mCustomView.getLayoutParams();
int newGravity = 0; int newGravity = 0;
switch (lp.gravity & Gravity.HORIZONTAL_GRAVITY_MASK) { switch (lp.gravity & Gravity.RELATIVE_HORIZONTAL_GRAVITY_MASK) {
case Gravity.LEFT: case Gravity.START:
newGravity = Gravity.CENTER_HORIZONTAL; newGravity = Gravity.CENTER_HORIZONTAL;
break; break;
case Gravity.CENTER_HORIZONTAL: case Gravity.CENTER_HORIZONTAL:
newGravity = Gravity.RIGHT; newGravity = Gravity.END;
break; break;
case Gravity.RIGHT: case Gravity.END:
newGravity = Gravity.LEFT; newGravity = Gravity.START;
break; break;
} }
lp.gravity = lp.gravity & ~Gravity.HORIZONTAL_GRAVITY_MASK | newGravity; lp.gravity = lp.gravity & ~Gravity.RELATIVE_HORIZONTAL_GRAVITY_MASK | newGravity;
bar.setCustomView(mCustomView, lp); bar.setCustomView(mCustomView, lp);
return; return;
} }