aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDanny Baumann <dannybaumann@web.de>2014-07-08 10:05:35 (GMT)
committerDanny Baumann <dannybaumann@web.de>2014-07-08 10:06:04 (GMT)
commitc012ca5b623e96a1e545d499ed43b3f649ba136f (patch)
tree501420f33dd1c607e439a200ae31392a2a1ba6d4
parented75f22737328749672e71f94be81963214d8665 (diff)
downloadandroid_packages_wallpapers_PhotoPhase-c012ca5b623e96a1e545d499ed43b3f649ba136f.zip
android_packages_wallpapers_PhotoPhase-c012ca5b623e96a1e545d499ed43b3f649ba136f.tar.gz
android_packages_wallpapers_PhotoPhase-c012ca5b623e96a1e545d499ed43b3f649ba136f.tar.bz2
Fix color picker layout.
Change-Id: I9bdd9cfce4d9fefd59c41fa090ce822e2990f00e
-rw-r--r--src/afzkl/development/mColorPicker/views/ColorDialogView.java37
1 files changed, 16 insertions, 21 deletions
diff --git a/src/afzkl/development/mColorPicker/views/ColorDialogView.java b/src/afzkl/development/mColorPicker/views/ColorDialogView.java
index f82ea96..87c9e6a 100644
--- a/src/afzkl/development/mColorPicker/views/ColorDialogView.java
+++ b/src/afzkl/development/mColorPicker/views/ColorDialogView.java
@@ -36,8 +36,8 @@ import android.view.View;
import android.view.ViewGroup;
import android.view.inputmethod.EditorInfo;
import android.widget.EditText;
+import android.widget.FrameLayout;
import android.widget.LinearLayout;
-import android.widget.RelativeLayout;
import android.widget.ScrollView;
import android.widget.TextView;
@@ -48,7 +48,7 @@ import java.util.concurrent.atomic.AtomicInteger;
* A view use directly into a dialog. It contains a one {@link ColorPickerView}
* and two {@link ColorPanelView} (the current color and the new color)
*/
-public class ColorDialogView extends RelativeLayout
+public class ColorDialogView extends FrameLayout
implements OnColorChangedListener, TextWatcher {
private static final int DEFAULT_MARGIN_DP = 16;
@@ -117,7 +117,7 @@ public class ColorDialogView extends RelativeLayout
final int dlgMarging = (int)convertDpToPixel(DEFAULT_MARGIN_DP);
ScrollView sv = new ScrollView(getContext());
sv.setId(internalGenerateViewId());
- RelativeLayout.LayoutParams lp = new RelativeLayout.LayoutParams(
+ FrameLayout.LayoutParams lp = new FrameLayout.LayoutParams(
android.view.ViewGroup.LayoutParams.MATCH_PARENT,
android.view.ViewGroup.LayoutParams.WRAP_CONTENT);
lp.setMargins(dlgMarging, 0, dlgMarging, 0);
@@ -127,7 +127,7 @@ public class ColorDialogView extends RelativeLayout
// Now the vertical layout
LinearLayout ll = new LinearLayout(getContext());
ll.setId(internalGenerateViewId());
- lp = new RelativeLayout.LayoutParams(
+ lp = new ScrollView.LayoutParams(
android.view.ViewGroup.LayoutParams.MATCH_PARENT,
android.view.ViewGroup.LayoutParams.MATCH_PARENT);
ll.setLayoutParams(lp);
@@ -135,13 +135,13 @@ public class ColorDialogView extends RelativeLayout
sv.addView(ll);
// Creates the color input field
- int id = createColorInput(ll);
+ createColorInput(ll);
// Creates the color picker
- id = createColorPicker(ll, id);
+ createColorPicker(ll);
// Creates the current color and new color panels
- id = createColorsPanel(ll, id);
+ createColorsPanel(ll);
// Add the scrollview
addView(sv);
@@ -164,7 +164,7 @@ public class ColorDialogView extends RelativeLayout
this.tvColorLabel = new TextView(getContext());
this.tvColorLabel.setText(this.mColorLabelText);
this.tvColorLabel.setTextSize(TypedValue.COMPLEX_UNIT_SP, DEFAULT_LABEL_TEXT_SIZE_SP);
- this.tvColorLabel.setGravity(Gravity.BOTTOM | Gravity.LEFT);
+ this.tvColorLabel.setGravity(Gravity.CENTER_VERTICAL | Gravity.LEFT);
this.tvColorLabel.setLayoutParams(lp2);
lp2 = new LinearLayout.LayoutParams(
@@ -205,11 +205,10 @@ public class ColorDialogView extends RelativeLayout
LinearLayout ll1 = new LinearLayout(getContext());
ll1.setId(internalGenerateViewId());
- RelativeLayout.LayoutParams lp = new RelativeLayout.LayoutParams(
+ LinearLayout.LayoutParams lp = new LinearLayout.LayoutParams(
android.view.ViewGroup.LayoutParams.MATCH_PARENT,
android.view.ViewGroup.LayoutParams.WRAP_CONTENT);
lp.setMargins(dlgMarging, 0, dlgMarging, 0);
- lp.addRule(RelativeLayout.ALIGN_PARENT_TOP);
ll1.setLayoutParams(lp);
ll1.addView(this.tvColorLabel);
ll1.addView(this.etColor);
@@ -222,19 +221,18 @@ public class ColorDialogView extends RelativeLayout
* Method that creates the color picker
*
* @param parent The parent layout
- * @param belowOf The anchor view
* @return id The layout id
*/
- private int createColorPicker(ViewGroup parent, int belowOf) {
+ private int createColorPicker(ViewGroup parent) {
final int dlgMarging = (int)convertDpToPixel(DEFAULT_MARGIN_DP);
this.mPickerView = new ColorPickerView(getContext());
this.mPickerView.setId(internalGenerateViewId());
this.mPickerView.setOnColorChangedListener(this);
- RelativeLayout.LayoutParams lp = new RelativeLayout.LayoutParams(
+ LinearLayout.LayoutParams lp = new LinearLayout.LayoutParams(
android.view.ViewGroup.LayoutParams.MATCH_PARENT,
android.view.ViewGroup.LayoutParams.WRAP_CONTENT);
+ lp.gravity = Gravity.CENTER_HORIZONTAL;
lp.setMargins(dlgMarging, 0, dlgMarging, 0);
- lp.addRule(RelativeLayout.BELOW, belowOf);
this.mPickerView.setLayoutParams(lp);
parent.addView(this.mPickerView);
return this.mPickerView.getId();
@@ -244,10 +242,9 @@ public class ColorDialogView extends RelativeLayout
* Method that creates the colors panel (current and new)
*
* @param parent The parent layout
- * @param belowOf The anchor view
* @return id The layout id
*/
- private int createColorsPanel(ViewGroup parent, int belowOf) {
+ private int createColorsPanel(ViewGroup parent) {
final int dlgMarging = (int)convertDpToPixel(DEFAULT_MARGIN_DP);
final int panelHeight = (int)convertDpToPixel(DEFAULT_PANEL_HEIGHT_DP);
LinearLayout.LayoutParams lp2 = new LinearLayout.LayoutParams(
@@ -280,11 +277,10 @@ public class ColorDialogView extends RelativeLayout
LinearLayout ll1 = new LinearLayout(getContext());
ll1.setId(internalGenerateViewId());
- RelativeLayout.LayoutParams lp = new RelativeLayout.LayoutParams(
+ LinearLayout.LayoutParams lp = new LinearLayout.LayoutParams(
android.view.ViewGroup.LayoutParams.MATCH_PARENT,
android.view.ViewGroup.LayoutParams.WRAP_CONTENT);
lp.setMargins(dlgMarging, 0, dlgMarging, dlgMarging/2);
- lp.addRule(RelativeLayout.BELOW, belowOf);
ll1.setLayoutParams(lp);
ll1.addView(this.tvCurrent);
ll1.addView(sep1);
@@ -312,10 +308,9 @@ public class ColorDialogView extends RelativeLayout
LinearLayout ll2 = new LinearLayout(getContext());
ll2.setId(internalGenerateViewId());
- lp = new RelativeLayout.LayoutParams(
- android.view.ViewGroup.LayoutParams.MATCH_PARENT, panelHeight);
+ lp = new LinearLayout.LayoutParams(
+ ViewGroup.LayoutParams.MATCH_PARENT, panelHeight);
lp.setMargins(dlgMarging, 0, dlgMarging, dlgMarging/2);
- lp.addRule(RelativeLayout.BELOW, ll1.getId());
ll2.setLayoutParams(lp);
ll2.addView(this.mCurrentColorView);
ll2.addView(sep2);