summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorChung-yih Wang <cywang@google.com>2011-09-21 11:56:31 +0800
committerChung-yih Wang <cywang@google.com>2011-09-22 02:10:08 +0800
commit606093cd434a89f5ca941d3a6d6e8470eb768c67 (patch)
tree0fee2c946b1693aff799d950c7d81f0e26e3c056
parent9e9aff5145a9c3e1e4e99fbd779cd3b9b3c20848 (diff)
downloadCamera-606093cd434a89f5ca941d3a6d6e8470eb768c67.tar.gz
Fix the zoom control bar UI on phone.
+use drawable selector to activate/deactivate the zoom control bar +update/add zoom assets Change-Id: Ie429dd0d78c562c8d1045280f336ae74ea6ce898
-rw-r--r--res/drawable-hdpi/ic_zoom_big.9.pngbin206 -> 135 bytes
-rw-r--r--res/drawable-hdpi/ic_zoom_big_dark.9.pngbin0 -> 170 bytes
-rw-r--r--res/drawable-hdpi/ic_zoom_in_holo_dark.pngbin0 -> 515 bytes
-rw-r--r--res/drawable-hdpi/ic_zoom_in_holo_light.pngbin515 -> 215 bytes
-rw-r--r--res/drawable-hdpi/ic_zoom_out_holo_dark.pngbin0 -> 379 bytes
-rw-r--r--res/drawable-hdpi/ic_zoom_out_holo_light.pngbin379 -> 184 bytes
-rw-r--r--res/drawable-mdpi/ic_zoom_big.9.pngbin173 -> 132 bytes
-rw-r--r--res/drawable-mdpi/ic_zoom_big_dark.9.pngbin0 -> 168 bytes
-rw-r--r--res/drawable-mdpi/ic_zoom_in_holo_dark.pngbin0 -> 465 bytes
-rw-r--r--res/drawable-mdpi/ic_zoom_in_holo_light.pngbin465 -> 223 bytes
-rw-r--r--res/drawable-mdpi/ic_zoom_out_holo_dark.pngbin0 -> 366 bytes
-rw-r--r--res/drawable-mdpi/ic_zoom_out_holo_light.pngbin366 -> 178 bytes
-rw-r--r--res/drawable-w1024dp-hdpi/ic_zoom_in_holo_dark.pngbin0 -> 657 bytes
-rw-r--r--res/drawable-w1024dp-hdpi/ic_zoom_in_holo_light.pngbin657 -> 269 bytes
-rw-r--r--res/drawable-w1024dp-hdpi/ic_zoom_out_holo_dark.pngbin0 -> 450 bytes
-rw-r--r--res/drawable-w1024dp-hdpi/ic_zoom_out_holo_light.pngbin450 -> 202 bytes
-rw-r--r--res/drawable-w1024dp-mdpi/ic_zoom_in_holo_dark.pngbin0 -> 545 bytes
-rw-r--r--res/drawable-w1024dp-mdpi/ic_zoom_in_holo_light.pngbin545 -> 212 bytes
-rw-r--r--res/drawable-w1024dp-mdpi/ic_zoom_out_holo_dark.pngbin0 -> 434 bytes
-rw-r--r--res/drawable-w1024dp-mdpi/ic_zoom_out_holo_light.pngbin434 -> 183 bytes
-rw-r--r--res/drawable-w1024dp-xhdpi/ic_zoom_out_holo_dark.pngbin0 -> 492 bytes
-rw-r--r--res/drawable-w1024dp-xhdpi/ic_zoom_out_holo_light.pngbin492 -> 221 bytes
-rw-r--r--res/drawable-xhdpi/ic_zoom_big.9.pngbin211 -> 92 bytes
-rw-r--r--res/drawable-xhdpi/ic_zoom_big_dark.9.pngbin0 -> 171 bytes
-rw-r--r--res/drawable-xhdpi/ic_zoom_in_holo_dark.pngbin0 -> 580 bytes
-rw-r--r--res/drawable-xhdpi/ic_zoom_in_holo_light.pngbin580 -> 251 bytes
-rw-r--r--res/drawable-xhdpi/ic_zoom_out_holo_dark.pngbin0 -> 411 bytes
-rw-r--r--res/drawable-xhdpi/ic_zoom_out_holo_light.pngbin411 -> 200 bytes
-rw-r--r--res/drawable/ic_zoom_in.xml21
-rw-r--r--res/drawable/ic_zoom_out.xml21
-rw-r--r--res/drawable/zoom_slider_bar.xml21
-rw-r--r--res/layout/indicator_bar.xml1
-rw-r--r--src/com/android/camera/ui/ZoomControl.java18
-rw-r--r--src/com/android/camera/ui/ZoomControlBar.java78
34 files changed, 122 insertions, 38 deletions
diff --git a/res/drawable-hdpi/ic_zoom_big.9.png b/res/drawable-hdpi/ic_zoom_big.9.png
index cc40dece..8e6380e9 100644
--- a/res/drawable-hdpi/ic_zoom_big.9.png
+++ b/res/drawable-hdpi/ic_zoom_big.9.png
Binary files differ
diff --git a/res/drawable-hdpi/ic_zoom_big_dark.9.png b/res/drawable-hdpi/ic_zoom_big_dark.9.png
new file mode 100644
index 00000000..340254b9
--- /dev/null
+++ b/res/drawable-hdpi/ic_zoom_big_dark.9.png
Binary files differ
diff --git a/res/drawable-hdpi/ic_zoom_in_holo_dark.png b/res/drawable-hdpi/ic_zoom_in_holo_dark.png
new file mode 100644
index 00000000..89b5f155
--- /dev/null
+++ b/res/drawable-hdpi/ic_zoom_in_holo_dark.png
Binary files differ
diff --git a/res/drawable-hdpi/ic_zoom_in_holo_light.png b/res/drawable-hdpi/ic_zoom_in_holo_light.png
index 89b5f155..b96da3b9 100644
--- a/res/drawable-hdpi/ic_zoom_in_holo_light.png
+++ b/res/drawable-hdpi/ic_zoom_in_holo_light.png
Binary files differ
diff --git a/res/drawable-hdpi/ic_zoom_out_holo_dark.png b/res/drawable-hdpi/ic_zoom_out_holo_dark.png
new file mode 100644
index 00000000..f4a25891
--- /dev/null
+++ b/res/drawable-hdpi/ic_zoom_out_holo_dark.png
Binary files differ
diff --git a/res/drawable-hdpi/ic_zoom_out_holo_light.png b/res/drawable-hdpi/ic_zoom_out_holo_light.png
index f4a25891..2f6a7b51 100644
--- a/res/drawable-hdpi/ic_zoom_out_holo_light.png
+++ b/res/drawable-hdpi/ic_zoom_out_holo_light.png
Binary files differ
diff --git a/res/drawable-mdpi/ic_zoom_big.9.png b/res/drawable-mdpi/ic_zoom_big.9.png
index 9c2019c1..e551fd06 100644
--- a/res/drawable-mdpi/ic_zoom_big.9.png
+++ b/res/drawable-mdpi/ic_zoom_big.9.png
Binary files differ
diff --git a/res/drawable-mdpi/ic_zoom_big_dark.9.png b/res/drawable-mdpi/ic_zoom_big_dark.9.png
new file mode 100644
index 00000000..4c12ae5e
--- /dev/null
+++ b/res/drawable-mdpi/ic_zoom_big_dark.9.png
Binary files differ
diff --git a/res/drawable-mdpi/ic_zoom_in_holo_dark.png b/res/drawable-mdpi/ic_zoom_in_holo_dark.png
new file mode 100644
index 00000000..4f332780
--- /dev/null
+++ b/res/drawable-mdpi/ic_zoom_in_holo_dark.png
Binary files differ
diff --git a/res/drawable-mdpi/ic_zoom_in_holo_light.png b/res/drawable-mdpi/ic_zoom_in_holo_light.png
index 4f332780..fb840e11 100644
--- a/res/drawable-mdpi/ic_zoom_in_holo_light.png
+++ b/res/drawable-mdpi/ic_zoom_in_holo_light.png
Binary files differ
diff --git a/res/drawable-mdpi/ic_zoom_out_holo_dark.png b/res/drawable-mdpi/ic_zoom_out_holo_dark.png
new file mode 100644
index 00000000..26318944
--- /dev/null
+++ b/res/drawable-mdpi/ic_zoom_out_holo_dark.png
Binary files differ
diff --git a/res/drawable-mdpi/ic_zoom_out_holo_light.png b/res/drawable-mdpi/ic_zoom_out_holo_light.png
index 26318944..55bc997f 100644
--- a/res/drawable-mdpi/ic_zoom_out_holo_light.png
+++ b/res/drawable-mdpi/ic_zoom_out_holo_light.png
Binary files differ
diff --git a/res/drawable-w1024dp-hdpi/ic_zoom_in_holo_dark.png b/res/drawable-w1024dp-hdpi/ic_zoom_in_holo_dark.png
new file mode 100644
index 00000000..99d5ef4e
--- /dev/null
+++ b/res/drawable-w1024dp-hdpi/ic_zoom_in_holo_dark.png
Binary files differ
diff --git a/res/drawable-w1024dp-hdpi/ic_zoom_in_holo_light.png b/res/drawable-w1024dp-hdpi/ic_zoom_in_holo_light.png
index 99d5ef4e..42c0a75c 100644
--- a/res/drawable-w1024dp-hdpi/ic_zoom_in_holo_light.png
+++ b/res/drawable-w1024dp-hdpi/ic_zoom_in_holo_light.png
Binary files differ
diff --git a/res/drawable-w1024dp-hdpi/ic_zoom_out_holo_dark.png b/res/drawable-w1024dp-hdpi/ic_zoom_out_holo_dark.png
new file mode 100644
index 00000000..5fa4c954
--- /dev/null
+++ b/res/drawable-w1024dp-hdpi/ic_zoom_out_holo_dark.png
Binary files differ
diff --git a/res/drawable-w1024dp-hdpi/ic_zoom_out_holo_light.png b/res/drawable-w1024dp-hdpi/ic_zoom_out_holo_light.png
index 5fa4c954..5a8eac88 100644
--- a/res/drawable-w1024dp-hdpi/ic_zoom_out_holo_light.png
+++ b/res/drawable-w1024dp-hdpi/ic_zoom_out_holo_light.png
Binary files differ
diff --git a/res/drawable-w1024dp-mdpi/ic_zoom_in_holo_dark.png b/res/drawable-w1024dp-mdpi/ic_zoom_in_holo_dark.png
new file mode 100644
index 00000000..fd352072
--- /dev/null
+++ b/res/drawable-w1024dp-mdpi/ic_zoom_in_holo_dark.png
Binary files differ
diff --git a/res/drawable-w1024dp-mdpi/ic_zoom_in_holo_light.png b/res/drawable-w1024dp-mdpi/ic_zoom_in_holo_light.png
index fd352072..3d55439b 100644
--- a/res/drawable-w1024dp-mdpi/ic_zoom_in_holo_light.png
+++ b/res/drawable-w1024dp-mdpi/ic_zoom_in_holo_light.png
Binary files differ
diff --git a/res/drawable-w1024dp-mdpi/ic_zoom_out_holo_dark.png b/res/drawable-w1024dp-mdpi/ic_zoom_out_holo_dark.png
new file mode 100644
index 00000000..e2828727
--- /dev/null
+++ b/res/drawable-w1024dp-mdpi/ic_zoom_out_holo_dark.png
Binary files differ
diff --git a/res/drawable-w1024dp-mdpi/ic_zoom_out_holo_light.png b/res/drawable-w1024dp-mdpi/ic_zoom_out_holo_light.png
index e2828727..1a5475b8 100644
--- a/res/drawable-w1024dp-mdpi/ic_zoom_out_holo_light.png
+++ b/res/drawable-w1024dp-mdpi/ic_zoom_out_holo_light.png
Binary files differ
diff --git a/res/drawable-w1024dp-xhdpi/ic_zoom_out_holo_dark.png b/res/drawable-w1024dp-xhdpi/ic_zoom_out_holo_dark.png
new file mode 100644
index 00000000..34064d73
--- /dev/null
+++ b/res/drawable-w1024dp-xhdpi/ic_zoom_out_holo_dark.png
Binary files differ
diff --git a/res/drawable-w1024dp-xhdpi/ic_zoom_out_holo_light.png b/res/drawable-w1024dp-xhdpi/ic_zoom_out_holo_light.png
index 34064d73..6297de4d 100644
--- a/res/drawable-w1024dp-xhdpi/ic_zoom_out_holo_light.png
+++ b/res/drawable-w1024dp-xhdpi/ic_zoom_out_holo_light.png
Binary files differ
diff --git a/res/drawable-xhdpi/ic_zoom_big.9.png b/res/drawable-xhdpi/ic_zoom_big.9.png
index 1e273788..48b9e246 100644
--- a/res/drawable-xhdpi/ic_zoom_big.9.png
+++ b/res/drawable-xhdpi/ic_zoom_big.9.png
Binary files differ
diff --git a/res/drawable-xhdpi/ic_zoom_big_dark.9.png b/res/drawable-xhdpi/ic_zoom_big_dark.9.png
new file mode 100644
index 00000000..b33b5462
--- /dev/null
+++ b/res/drawable-xhdpi/ic_zoom_big_dark.9.png
Binary files differ
diff --git a/res/drawable-xhdpi/ic_zoom_in_holo_dark.png b/res/drawable-xhdpi/ic_zoom_in_holo_dark.png
new file mode 100644
index 00000000..78178cd8
--- /dev/null
+++ b/res/drawable-xhdpi/ic_zoom_in_holo_dark.png
Binary files differ
diff --git a/res/drawable-xhdpi/ic_zoom_in_holo_light.png b/res/drawable-xhdpi/ic_zoom_in_holo_light.png
index 78178cd8..e950b13a 100644
--- a/res/drawable-xhdpi/ic_zoom_in_holo_light.png
+++ b/res/drawable-xhdpi/ic_zoom_in_holo_light.png
Binary files differ
diff --git a/res/drawable-xhdpi/ic_zoom_out_holo_dark.png b/res/drawable-xhdpi/ic_zoom_out_holo_dark.png
new file mode 100644
index 00000000..426aac80
--- /dev/null
+++ b/res/drawable-xhdpi/ic_zoom_out_holo_dark.png
Binary files differ
diff --git a/res/drawable-xhdpi/ic_zoom_out_holo_light.png b/res/drawable-xhdpi/ic_zoom_out_holo_light.png
index 426aac80..c06ca66e 100644
--- a/res/drawable-xhdpi/ic_zoom_out_holo_light.png
+++ b/res/drawable-xhdpi/ic_zoom_out_holo_light.png
Binary files differ
diff --git a/res/drawable/ic_zoom_in.xml b/res/drawable/ic_zoom_in.xml
new file mode 100644
index 00000000..7ba87ae2
--- /dev/null
+++ b/res/drawable/ic_zoom_in.xml
@@ -0,0 +1,21 @@
+<?xml version="1.0" encoding="utf-8"?>
+<!-- Copyright (C) 2011 The Android Open Source Project
+
+ Licensed under the Apache License, Version 2.0 (the "License");
+ you may not use this file except in compliance with the License.
+ You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
+-->
+
+<selector xmlns:android="http://schemas.android.com/apk/res/android">
+ <item android:state_activated="true" android:drawable="@drawable/ic_zoom_in_holo_light" />
+ <item android:drawable="@drawable/ic_zoom_in_holo_dark" />
+</selector>
+
diff --git a/res/drawable/ic_zoom_out.xml b/res/drawable/ic_zoom_out.xml
new file mode 100644
index 00000000..1d46cbc4
--- /dev/null
+++ b/res/drawable/ic_zoom_out.xml
@@ -0,0 +1,21 @@
+<?xml version="1.0" encoding="utf-8"?>
+<!-- Copyright (C) 2011 The Android Open Source Project
+
+ Licensed under the Apache License, Version 2.0 (the "License");
+ you may not use this file except in compliance with the License.
+ You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
+-->
+
+<selector xmlns:android="http://schemas.android.com/apk/res/android">
+ <item android:state_activated="true" android:drawable="@drawable/ic_zoom_out_holo_light" />
+ <item android:drawable="@drawable/ic_zoom_out_holo_dark" />
+</selector>
+
diff --git a/res/drawable/zoom_slider_bar.xml b/res/drawable/zoom_slider_bar.xml
new file mode 100644
index 00000000..234fd0f0
--- /dev/null
+++ b/res/drawable/zoom_slider_bar.xml
@@ -0,0 +1,21 @@
+<?xml version="1.0" encoding="utf-8"?>
+<!-- Copyright (C) 2011 The Android Open Source Project
+
+ Licensed under the Apache License, Version 2.0 (the "License");
+ you may not use this file except in compliance with the License.
+ You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
+-->
+
+<selector xmlns:android="http://schemas.android.com/apk/res/android">
+ <item android:state_activated="true" android:drawable="@drawable/ic_zoom_big" />
+ <item android:drawable="@drawable/ic_zoom_big_dark" />
+</selector>
+
diff --git a/res/layout/indicator_bar.xml b/res/layout/indicator_bar.xml
index c39fb933..11276e35 100644
--- a/res/layout/indicator_bar.xml
+++ b/res/layout/indicator_bar.xml
@@ -49,7 +49,6 @@
android:id="@+id/zoom_control"
android:layout_width="match_parent"
android:layout_height="match_parent"
- android:layout_centerHorizontal="true"
android:visibility="gone" />
<com.android.camera.ui.RotateImageView
android:id="@+id/second_level_indicator_bar_icon"
diff --git a/src/com/android/camera/ui/ZoomControl.java b/src/com/android/camera/ui/ZoomControl.java
index 662ee927..4258fd90 100644
--- a/src/com/android/camera/ui/ZoomControl.java
+++ b/src/com/android/camera/ui/ZoomControl.java
@@ -20,7 +20,6 @@ import com.android.camera.R;
import android.content.Context;
import android.os.Handler;
-import android.os.SystemClock;
import android.util.AttributeSet;
import android.view.View;
import android.widget.ImageView;
@@ -75,9 +74,9 @@ public abstract class ZoomControl extends RelativeLayout {
public ZoomControl(Context context, AttributeSet attrs) {
super(context, attrs);
- mZoomIn = addImageView(context, R.drawable.ic_zoom_in_holo_light);
- mZoomSlider = addImageView(context, R.drawable.btn_zoom_slider);
- mZoomOut = addImageView(context, R.drawable.ic_zoom_out_holo_light);
+ mZoomIn = addImageView(context, R.drawable.ic_zoom_in);
+ mZoomSlider = addImageView(context, R.drawable.ic_zoom_slider);
+ mZoomOut = addImageView(context, R.drawable.ic_zoom_out);
mHandler = new Handler();
}
@@ -105,6 +104,10 @@ public abstract class ZoomControl extends RelativeLayout {
public void setZoomMax(int zoomMax) {
mZoomMax = zoomMax;
+
+ // Layout should be requested as the maximum zoom level is the key to
+ // show the correct zoom slider position.
+ requestLayout();
}
public void setOnZoomChangeListener(OnZoomChangedListener listener) {
@@ -219,4 +222,11 @@ public abstract class ZoomControl extends RelativeLayout {
}
}
}
+
+ @Override
+ public void setActivated(boolean activated) {
+ super.setActivated(activated);
+ mZoomIn.setActivated(activated);
+ mZoomOut.setActivated(activated);
+ }
}
diff --git a/src/com/android/camera/ui/ZoomControlBar.java b/src/com/android/camera/ui/ZoomControlBar.java
index 6bbb8f12..06cff0d3 100644
--- a/src/com/android/camera/ui/ZoomControlBar.java
+++ b/src/com/android/camera/ui/ZoomControlBar.java
@@ -20,7 +20,6 @@ import com.android.camera.R;
import com.android.camera.Util;
import android.content.Context;
-import android.os.Handler;
import android.util.AttributeSet;
import android.view.MotionEvent;
import android.view.View;
@@ -30,60 +29,76 @@ import android.view.View;
*/
public class ZoomControlBar extends ZoomControl {
private static final String TAG = "ZoomControlBar";
- private static int THRESHOLD_FIRST_MOVE = Util.dpToPixel(10); // pixels
+ private static final int THRESHOLD_FIRST_MOVE = Util.dpToPixel(10); // pixels
+ // Space between indicator icon and the zoom-in/out icon.
+ private static final int ICON_SPACING = Util.dpToPixel(12);
+
private View mBar;
private boolean mStartChanging;
+ private int mSliderLength;
public ZoomControlBar(Context context, AttributeSet attrs) {
super(context, attrs);
mBar = new View(context);
- mBar.setBackgroundResource(R.drawable.ic_zoom_big);
+ mBar.setBackgroundResource(R.drawable.zoom_slider_bar);
addView(mBar);
}
@Override
- public boolean dispatchTouchEvent(MotionEvent event) {
- if (!onFilterTouchEventForSecurity(event)) return false;
-
- int action = event.getAction();
-
- if (!isEnabled()) return false;
-
- double y = (double) event.getY();
+ public void setActivated(boolean activated) {
+ super.setActivated(activated);
+ mBar.setActivated(activated);
+ }
+ private int getSliderPosition(int y) {
// Calculate the absolute offset of the slider in the zoom control bar.
// For left-hand users, as the device is rotated for 180 degree for
// landscape mode, the zoom-in bottom should be on the top, so the
// position should be reversed.
- int offset = 5 * getWidth() / 4; // the padding and the icon height
+ int totalIconHeight = mZoomIn.getHeight() + ICON_SPACING;
int height = getHeight();
- int range = height - 2 * offset; // the range of the zoom slider
int pos; // the relative position in the zoom slider bar
if (mDegree == 180) {
- pos = (int) y - offset;
+ pos = y - totalIconHeight;
} else {
- pos = height - (int) y - offset;
+ pos = height - totalIconHeight - y;
+ }
+ if (mSliderLength == 0) {
+ mSliderLength = height - (2 * totalIconHeight);
}
if (pos < 0) pos = 0;
- if (pos > range) pos = range;
+ if (pos > mSliderLength) pos = mSliderLength;
+ return pos;
+ }
+
+ @Override
+ public boolean dispatchTouchEvent(MotionEvent event) {
+ if (!onFilterTouchEventForSecurity(event)) return false;
+
+ int action = event.getAction();
+ if (!isEnabled() || (getHeight() == 0)) return false;
switch (action) {
case MotionEvent.ACTION_OUTSIDE:
case MotionEvent.ACTION_CANCEL:
+ case MotionEvent.ACTION_UP:
+ setActivated(false);
closeZoomControl();
break;
case MotionEvent.ACTION_DOWN:
+ setActivated(true);
mStartChanging = false;
case MotionEvent.ACTION_MOVE:
// Make sure the movement is large enough before we start
// changing the zoom.
+ int pos = getSliderPosition((int) event.getY());
if (!mStartChanging && (Math.abs(mSliderPosition - pos)
> THRESHOLD_FIRST_MOVE)) {
mStartChanging = true;
}
if (mStartChanging) {
- performZoom(1.0d * pos / range);
+ performZoom(1.0d * pos / mSliderLength);
mSliderPosition = pos;
}
requestLayout();
@@ -102,28 +117,25 @@ public class ZoomControlBar extends ZoomControl {
protected void onLayout(
boolean changed, int left, int top, int right, int bottom) {
if (mZoomMax == 0) return;
-
int width = right - left;
int height = bottom - top;
- int range = height - 10 * width / 4;
- int pos;
-
- // TODO: remove offset once we have correct ic_zoom_big.9.png.
- int offset = 3 * width / 4;
-
+ int iconHeight = mZoomIn.getMeasuredHeight();
+ mBar.layout(0, iconHeight + ICON_SPACING,
+ width, height - iconHeight - ICON_SPACING);
// For left-hand users, as the device is rotated for 180 degree,
// the zoom-in button should be on the top.
+ int pos; // slider position
if (mDegree == 180) {
- mZoomOut.layout(0, 0, width, width);
- mZoomIn.layout(0, height - width, width, height);
- pos = offset + mZoomIndex * range / mZoomMax;
- mZoomSlider.layout(0, pos, width, pos + width);
+ mZoomOut.layout(0, 0, width, iconHeight);
+ mZoomIn.layout(0, height - iconHeight, width, height);
+ pos = mBar.getTop() + mSliderPosition;
} else {
- mZoomIn.layout(0, 0, width, width);
- mZoomOut.layout(0, height - width, width, height);
- pos = offset + (mZoomMax - mZoomIndex) * range / mZoomMax;
- mZoomSlider.layout(0, pos, width, pos + width);
+ mZoomIn.layout(0, 0, width, iconHeight);
+ mZoomOut.layout(0, height - iconHeight, width, height);
+ pos = mBar.getBottom() - mSliderPosition;
}
- mBar.layout(0, width, width, bottom - top - width);
+ int sliderHeight = mZoomSlider.getMeasuredHeight();
+ mZoomSlider.layout(0, (pos - sliderHeight / 2),
+ width, (pos + sliderHeight / 2));
}
}