summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJames Kung <kingkung@google.com>2013-04-11 16:31:53 -0700
committerJames Kung <kingkung@google.com>2013-04-11 16:37:40 -0700
commit51da77ac265fc6e46403bc6f8d3cca57e57427d7 (patch)
treee15bf92ed9b555d496e0d958b9580202441d788f
parent2e00aa34c051111529290cf23c6ba940c2c0c142 (diff)
downloaddatetimepicker-51da77ac265fc6e46403bc6f8d3cca57e57427d7.tar.gz
Fixing date picker layout across all devices
Bug: 8599662 Change-Id: Ia47599a0f502117239df057efb12ab4133498975
-rw-r--r--res/layout-land/date_picker_dialog.xml31
-rw-r--r--res/layout-sw270dp-h560dp-land/date_picker_dialog.xml29
-rw-r--r--res/layout-sw270dp-h560dp/date_picker_dialog.xml31
-rw-r--r--res/layout/date_picker_dialog.xml31
-rw-r--r--res/layout/date_picker_done_button.xml3
-rw-r--r--res/layout/date_picker_header_view.xml2
-rw-r--r--res/layout/date_picker_selected_date.xml5
-rw-r--r--res/layout/date_picker_view_animator.xml21
-rw-r--r--res/values-land/dimens.xml2
-rw-r--r--res/values-sw270dp-h560dp-land/dimens.xml28
-rw-r--r--res/values-sw270dp-h560dp/dimens.xml2
-rw-r--r--res/values-sw600dp-land/dimens.xml4
-rw-r--r--res/values-sw600dp/dimens.xml12
-rw-r--r--res/values/colors.xml2
-rw-r--r--res/values/dimens.xml10
-rw-r--r--src/com/android/datetimepicker/date/SimpleMonthView.java4
-rw-r--r--src/com/android/datetimepicker/date/YearPickerView.java4
17 files changed, 100 insertions, 121 deletions
diff --git a/res/layout-land/date_picker_dialog.xml b/res/layout-land/date_picker_dialog.xml
index 0e99a4b..2c131ea 100644
--- a/res/layout-land/date_picker_dialog.xml
+++ b/res/layout-land/date_picker_dialog.xml
@@ -16,20 +16,27 @@
-->
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
- android:layout_height="@dimen/date_picker_dialog_height"
+ android:layout_height="@dimen/date_picker_view_animator_height"
android:gravity="center"
android:orientation="horizontal" >
<LinearLayout
- android:layout_width="@dimen/date_picker_width"
- android:layout_height="@dimen/date_picker_dialog_height"
+ android:layout_width="wrap_content"
+ android:layout_height="match_parent"
android:layout_gravity="center"
android:background="@color/white"
android:orientation="vertical" >
- <include layout="@layout/date_picker_header_view" />
+ <LinearLayout
+ android:layout_width="wrap_content"
+ android:layout_height="0dip"
+ android:layout_weight="1"
+ android:orientation="vertical" >
+
+ <include layout="@layout/date_picker_header_view" />
- <include layout="@layout/date_picker_selected_date" />
+ <include layout="@layout/date_picker_selected_date" />
+ </LinearLayout>
<View
android:layout_width="match_parent"
@@ -44,18 +51,6 @@
android:layout_height="match_parent"
android:background="@color/line_background" />
- <FrameLayout
- android:layout_width="@dimen/pager_width"
- android:layout_height="match_parent"
- android:layout_gravity="center"
- android:background="@color/calendar_pager" >
-
- <ViewAnimator
- android:id="@+id/animator"
- android:layout_width="@dimen/pager_width"
- android:layout_height="@dimen/pager_height"
- android:background="@color/calendar_pager"
- android:gravity="center" />
- </FrameLayout>
+ <include layout="@layout/date_picker_view_animator" />
</LinearLayout> \ No newline at end of file
diff --git a/res/layout-sw270dp-h560dp-land/date_picker_dialog.xml b/res/layout-sw270dp-h560dp-land/date_picker_dialog.xml
index 0e99a4b..fa28888 100644
--- a/res/layout-sw270dp-h560dp-land/date_picker_dialog.xml
+++ b/res/layout-sw270dp-h560dp-land/date_picker_dialog.xml
@@ -16,23 +16,26 @@
-->
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
- android:layout_height="@dimen/date_picker_dialog_height"
+ android:layout_height="wrap_content"
android:gravity="center"
android:orientation="horizontal" >
<LinearLayout
- android:layout_width="@dimen/date_picker_width"
- android:layout_height="@dimen/date_picker_dialog_height"
+ android:layout_width="wrap_content"
+ android:layout_height="wrap_content"
android:layout_gravity="center"
android:background="@color/white"
android:orientation="vertical" >
<include layout="@layout/date_picker_header_view" />
- <include layout="@layout/date_picker_selected_date" />
+ <include
+ android:layout_height="0dip"
+ android:layout_weight="1"
+ layout="@layout/date_picker_selected_date" />
<View
- android:layout_width="match_parent"
+ android:layout_width="@dimen/date_picker_component_width"
android:layout_height="1dip"
android:background="@color/line_background" />
@@ -41,21 +44,9 @@
<View
android:layout_width="1dip"
- android:layout_height="match_parent"
+ android:layout_height="@dimen/date_picker_view_animator_height"
android:background="@color/line_background" />
- <FrameLayout
- android:layout_width="@dimen/pager_width"
- android:layout_height="match_parent"
- android:layout_gravity="center"
- android:background="@color/calendar_pager" >
-
- <ViewAnimator
- android:id="@+id/animator"
- android:layout_width="@dimen/pager_width"
- android:layout_height="@dimen/pager_height"
- android:background="@color/calendar_pager"
- android:gravity="center" />
- </FrameLayout>
+ <include layout="@layout/date_picker_view_animator" />
</LinearLayout> \ No newline at end of file
diff --git a/res/layout-sw270dp-h560dp/date_picker_dialog.xml b/res/layout-sw270dp-h560dp/date_picker_dialog.xml
index 4397f0d..bd0db52 100644
--- a/res/layout-sw270dp-h560dp/date_picker_dialog.xml
+++ b/res/layout-sw270dp-h560dp/date_picker_dialog.xml
@@ -1,5 +1,6 @@
<?xml version="1.0" encoding="utf-8"?>
-<!-- Copyright (C) 2013 The Android Open Source Project
+<!--
+ Copyright (C) 2013 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.
@@ -14,29 +15,29 @@
limitations under the License.
-->
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
- android:layout_width="@dimen/date_picker_width"
+ android:layout_width="wrap_content"
android:layout_height="match_parent"
+ android:background="@color/date_picker_view_animator"
android:gravity="center"
- android:orientation="vertical"
- android:background="@color/calendar_pager" >
+ android:orientation="vertical" >
- <include layout="@layout/date_picker_header_view" />
+ <LinearLayout
+ android:layout_width="wrap_content"
+ android:layout_height="@dimen/selected_calendar_layout_height"
+ android:orientation="vertical" >
- <include layout="@layout/date_picker_selected_date"
- android:id="@+id/date_picker_selected_date_layout" />
+ <include layout="@layout/date_picker_header_view" />
- <ViewAnimator
- android:id="@+id/animator"
- android:layout_width="@dimen/pager_width"
- android:layout_height="@dimen/pager_height"
- android:gravity="center"
- android:background="@color/calendar_pager" />
+ <include layout="@layout/date_picker_selected_date" />
+ </LinearLayout>
+
+ <include layout="@layout/date_picker_view_animator" />
<View
android:layout_width="match_parent"
android:layout_height="1dip"
android:background="@color/line_background" />
- <include layout="@layout/date_picker_done_button"
- android:id="@+id/date_picker_done_button" />
+ <include layout="@layout/date_picker_done_button" />
+
</LinearLayout> \ No newline at end of file
diff --git a/res/layout/date_picker_dialog.xml b/res/layout/date_picker_dialog.xml
index 658e7f6..3361cb3 100644
--- a/res/layout/date_picker_dialog.xml
+++ b/res/layout/date_picker_dialog.xml
@@ -1,5 +1,6 @@
<?xml version="1.0" encoding="utf-8"?>
-<!-- Copyright (C) 2013 The Android Open Source Project
+<!--
+ Copyright (C) 2013 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.
@@ -14,27 +15,27 @@
limitations under the License.
-->
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
- android:layout_width="@dimen/date_picker_width"
+ android:layout_width="@dimen/date_picker_component_width"
android:layout_height="match_parent"
+ android:background="@color/date_picker_view_animator"
android:gravity="center"
- android:orientation="vertical"
- android:background="@color/calendar_pager" >
+ android:orientation="vertical" >
- <include layout="@layout/date_picker_selected_date"
- android:id="@+id/date_picker_selected_date_layout" />
+ <LinearLayout
+ android:layout_width="wrap_content"
+ android:layout_height="@dimen/selected_calendar_layout_height"
+ android:orientation="vertical" >
- <ViewAnimator
- android:id="@+id/animator"
- android:layout_width="@dimen/pager_width"
- android:layout_height="@dimen/pager_height"
- android:gravity="center"
- android:background="@color/calendar_pager" />
+ <include layout="@layout/date_picker_selected_date" />
+ </LinearLayout>
+
+ <include layout="@layout/date_picker_view_animator" />
<View
- android:layout_width="match_parent"
+ android:layout_width="@dimen/date_picker_component_width"
android:layout_height="1dip"
android:background="@color/line_background" />
- <include layout="@layout/date_picker_done_button"
- android:id="@+id/date_picker_done_button" />
+ <include layout="@layout/date_picker_done_button" />
+
</LinearLayout> \ No newline at end of file
diff --git a/res/layout/date_picker_done_button.xml b/res/layout/date_picker_done_button.xml
index 4556f7a..9292d42 100644
--- a/res/layout/date_picker_done_button.xml
+++ b/res/layout/date_picker_done_button.xml
@@ -15,9 +15,8 @@
-->
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
style="?android:attr/buttonBarStyle"
- android:layout_width="match_parent"
+ android:layout_width="@dimen/date_picker_component_width"
android:layout_height="wrap_content"
- android:layout="@+id/done_layout"
android:orientation="vertical" >
<Button
diff --git a/res/layout/date_picker_header_view.xml b/res/layout/date_picker_header_view.xml
index a141616..1314a1a 100644
--- a/res/layout/date_picker_header_view.xml
+++ b/res/layout/date_picker_header_view.xml
@@ -16,7 +16,7 @@
-->
<TextView xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/date_picker_header"
- android:layout_width="match_parent"
+ android:layout_width="@dimen/date_picker_component_width"
android:layout_height="@dimen/date_picker_header_height"
android:background="@color/calendar_header"
android:gravity="center"
diff --git a/res/layout/date_picker_selected_date.xml b/res/layout/date_picker_selected_date.xml
index 3dda64c..22e5e92 100644
--- a/res/layout/date_picker_selected_date.xml
+++ b/res/layout/date_picker_selected_date.xml
@@ -17,8 +17,9 @@
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/day_picker_selected_date_layout"
- android:layout_width="match_parent"
- android:layout_height="@dimen/selected_date_layout_height"
+ android:layout_width="@dimen/date_picker_component_width"
+ android:layout_height="0dip"
+ android:layout_weight="1"
android:background="@color/white"
android:gravity="center"
android:orientation="vertical" >
diff --git a/res/layout/date_picker_view_animator.xml b/res/layout/date_picker_view_animator.xml
new file mode 100644
index 0000000..1b02070
--- /dev/null
+++ b/res/layout/date_picker_view_animator.xml
@@ -0,0 +1,21 @@
+<?xml version="1.0" encoding="utf-8"?>
+<!-- Copyright (C) 2013 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.
+-->
+<ViewAnimator xmlns:android="http://schemas.android.com/apk/res/android"
+ android:id="@+id/animator"
+ android:layout_width="@dimen/date_picker_component_width"
+ android:layout_height="@dimen/date_picker_view_animator_height"
+ android:gravity="center"
+ android:background="@color/date_picker_view_animator" /> \ No newline at end of file
diff --git a/res/values-land/dimens.xml b/res/values-land/dimens.xml
index 1029b3b..9789fde 100644
--- a/res/values-land/dimens.xml
+++ b/res/values-land/dimens.xml
@@ -22,9 +22,7 @@
xmlns:android="http://schemas.android.com/apk/res/android" >
<dimen name="dialog_height">200dip</dimen>
<dimen name="left_side_width">250dip</dimen>
- <dimen name="date_picker_dialog_height">282dip</dimen>
- <dimen name="selected_date_layout_height">210dp</dimen>
<dimen name="selected_date_year_size">30dp</dimen>
<dimen name="selected_date_day_size">100dp</dimen>
<dimen name="selected_date_month_size">30dp</dimen>
diff --git a/res/values-sw270dp-h560dp-land/dimens.xml b/res/values-sw270dp-h560dp-land/dimens.xml
deleted file mode 100644
index 545e85d..0000000
--- a/res/values-sw270dp-h560dp-land/dimens.xml
+++ /dev/null
@@ -1,28 +0,0 @@
-<?xml version="1.0" encoding="utf-8"?>
-<!--
-/*
-** Copyright 2013, 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.
-*/
--->
-
-<resources
- xmlns:xliff="urn:oasis:names:tc:xliff:document:1.2"
- xmlns:android="http://schemas.android.com/apk/res/android" >
-
- <dimen name="selected_date_layout_height">210dp</dimen>
- <dimen name="selected_date_year_size">30dp</dimen>
- <dimen name="selected_date_day_size">100dp</dimen>
- <dimen name="selected_date_month_size">30dp</dimen>
-</resources> \ No newline at end of file
diff --git a/res/values-sw270dp-h560dp/dimens.xml b/res/values-sw270dp-h560dp/dimens.xml
index 545e85d..a981940 100644
--- a/res/values-sw270dp-h560dp/dimens.xml
+++ b/res/values-sw270dp-h560dp/dimens.xml
@@ -21,7 +21,7 @@
xmlns:xliff="urn:oasis:names:tc:xliff:document:1.2"
xmlns:android="http://schemas.android.com/apk/res/android" >
- <dimen name="selected_date_layout_height">210dp</dimen>
+ <dimen name="selected_calendar_layout_height">240dp</dimen>
<dimen name="selected_date_year_size">30dp</dimen>
<dimen name="selected_date_day_size">100dp</dimen>
<dimen name="selected_date_month_size">30dp</dimen>
diff --git a/res/values-sw600dp-land/dimens.xml b/res/values-sw600dp-land/dimens.xml
index 390e753..608d2f9 100644
--- a/res/values-sw600dp-land/dimens.xml
+++ b/res/values-sw600dp-land/dimens.xml
@@ -20,6 +20,7 @@
<resources xmlns:xliff="urn:oasis:names:tc:xliff:document:1.2"
xmlns:android="http://schemas.android.com/apk/res/android">
+ <dimen name="date_picker_header_height">45dp</dimen>
<dimen name="time_label_right_padding">16sp</dimen>
<dimen name="time_label_size">64sp</dimen>
<dimen name="ampm_label_size">21sp</dimen>
@@ -28,7 +29,6 @@
<dimen name="separator_padding">5dip</dimen>
<dimen name="header_height">96dip</dimen>
<dimen name="footer_height">48dip</dimen>
- <dimen name="date_picker_dialog_height">410dip</dimen>
-
<dimen name="left_side_width">315dip</dimen>
+
</resources> \ No newline at end of file
diff --git a/res/values-sw600dp/dimens.xml b/res/values-sw600dp/dimens.xml
index 68dbc70..db3abb4 100644
--- a/res/values-sw600dp/dimens.xml
+++ b/res/values-sw600dp/dimens.xml
@@ -20,11 +20,9 @@
<resources xmlns:xliff="urn:oasis:names:tc:xliff:document:1.2"
xmlns:android="http://schemas.android.com/apk/res/android">
- <dimen name="pager_height">400dp</dimen>
- <dimen name="pager_width">400dp</dimen>
- <dimen name="date_picker_width">400dp</dimen>
- <dimen name="selected_date_layout_height">360dp</dimen>
- <dimen name="done_button_height">42dp</dimen>
+ <dimen name="date_picker_component_width">400dp</dimen>
+ <dimen name="date_picker_view_animator_height">400dp</dimen>
+ <dimen name="selected_calendar_layout_height">360dp</dimen>
<dimen name="date_picker_header_height">45dp</dimen>
<dimen name="month_list_item_header_height">75dp</dimen>
<dimen name="month_list_item_padding">24dp</dimen>
@@ -33,6 +31,8 @@
<dimen name="selected_date_year_size">45dp</dimen>
<dimen name="selected_date_day_size">150dp</dimen>
<dimen name="selected_date_month_size">45dp</dimen>
+ <dimen name="year_label_height">96dp</dimen>
+ <dimen name="year_label_text_size">33dp</dimen>
<dimen name="date_picker_header_text_size">21dp</dimen>
<dimen name="month_list_item_size">24sp</dimen>
<dimen name="month_label_size">24sp</dimen>
@@ -48,6 +48,6 @@
<dimen name="footer_height">60dip</dimen>
<dimen name="minimum_margin_sides">48dip</dimen>
<dimen name="minimum_margin_top_bottom">24dip</dimen>
-
<dimen name="picker_dimen">375dip</dimen>
+
</resources> \ No newline at end of file
diff --git a/res/values/colors.xml b/res/values/colors.xml
index 2672bfa..01117e5 100644
--- a/res/values/colors.xml
+++ b/res/values/colors.xml
@@ -29,7 +29,7 @@
<color name="date_picker_text_normal">#FF999999</color>
<color name="calendar_header">#999999</color>
- <color name="calendar_pager">#FFECEDEE</color>
+ <color name="date_picker_view_animator">#FFECEDEE</color>
<color name="calendar_selected_date_text">#FFD1D2D4</color>
<color name="done_button_color">#FFECEDEE</color>
</resources> \ No newline at end of file
diff --git a/res/values/dimens.xml b/res/values/dimens.xml
index 5ebc099..6852e1e 100644
--- a/res/values/dimens.xml
+++ b/res/values/dimens.xml
@@ -41,12 +41,12 @@
<dimen name="minimum_margin_top_bottom">24dip</dimen>
<dimen name="picker_dimen">270dip</dimen>
- <dimen name="pager_height">270dp</dimen>
- <dimen name="pager_width">270dp</dimen>
- <dimen name="date_picker_width">270dp</dimen>
- <dimen name="selected_date_layout_height">155dp</dimen>
- <dimen name="done_button_height">42dp</dimen>
+ <dimen name="date_picker_component_width">270dp</dimen>
<dimen name="date_picker_header_height">30dp</dimen>
+ <dimen name="selected_calendar_layout_height">155dp</dimen>
+ <dimen name="date_picker_view_animator_height">270dp</dimen>
+ <dimen name="done_button_height">42dp</dimen>
+
<dimen name="month_list_item_header_height">50dp</dimen>
<dimen name="month_day_label_text_size">10sp</dimen>
<dimen name="day_number_select_circle_radius">16dp</dimen>
diff --git a/src/com/android/datetimepicker/date/SimpleMonthView.java b/src/com/android/datetimepicker/date/SimpleMonthView.java
index 1beeef6..f4120d8 100644
--- a/src/com/android/datetimepicker/date/SimpleMonthView.java
+++ b/src/com/android/datetimepicker/date/SimpleMonthView.java
@@ -183,8 +183,8 @@ public class SimpleMonthView extends View {
DAY_SELECTED_CIRCLE_SIZE = res
.getDimensionPixelSize(R.dimen.day_number_select_circle_radius);
- mRowHeight = (res.getDimensionPixelOffset(R.dimen.pager_height) - MONTH_HEADER_SIZE)
- / MAX_NUM_ROWS;
+ mRowHeight = (res.getDimensionPixelOffset(R.dimen.date_picker_view_animator_height)
+ - MONTH_HEADER_SIZE) / MAX_NUM_ROWS;
// Sets up any standard paints that will be used
initView();
}
diff --git a/src/com/android/datetimepicker/date/YearPickerView.java b/src/com/android/datetimepicker/date/YearPickerView.java
index 10847f2..e5fec5e 100644
--- a/src/com/android/datetimepicker/date/YearPickerView.java
+++ b/src/com/android/datetimepicker/date/YearPickerView.java
@@ -51,13 +51,13 @@ public class YearPickerView extends ListView implements OnItemClickListener, OnD
super(context);
mController = controller;
mController.registerOnDateChangedListener(this);
- setVerticalFadingEdgeEnabled(true);
ViewGroup.LayoutParams frame = new ViewGroup.LayoutParams(LayoutParams.MATCH_PARENT,
LayoutParams.WRAP_CONTENT);
setLayoutParams(frame);
Resources res = context.getResources();
- mViewSize = res.getDimensionPixelOffset(R.dimen.pager_height);
+ mViewSize = res.getDimensionPixelOffset(R.dimen.date_picker_view_animator_height);
mChildSize = res.getDimensionPixelOffset(R.dimen.year_label_height);
+ setVerticalFadingEdgeEnabled(true);
setFadingEdgeLength(mChildSize / 3);
init(context);
setOnItemClickListener(this);