Merge "Fix padding on round devices for AlertDialogs." into nyc-mr1-dev

This commit is contained in:
TreeHugger Robot
2016-07-19 18:48:26 +00:00
committed by Android (Google) Code Review
7 changed files with 39 additions and 14 deletions

View File

@@ -618,7 +618,7 @@ public class AlertController {
}
}
private void setupTitle(ViewGroup topPanel) {
protected void setupTitle(ViewGroup topPanel) {
if (mCustomTitleView != null && mShowTitle) {
// Add the custom title view directly to the topPanel layout
final LayoutParams lp = new LayoutParams(
@@ -701,7 +701,7 @@ public class AlertController {
}
}
private void setupButtons(ViewGroup buttonPanel) {
protected void setupButtons(ViewGroup buttonPanel) {
int BIT_BUTTON_POSITIVE = 1;
int BIT_BUTTON_NEGATIVE = 2;
int BIT_BUTTON_NEUTRAL = 4;

View File

@@ -82,4 +82,20 @@ public class MicroAlertController extends AlertController {
}
}
}
@Override
protected void setupTitle(ViewGroup topPanel) {
super.setupTitle(topPanel);
if (topPanel.getVisibility() == View.GONE) {
topPanel.setVisibility(View.INVISIBLE);
}
}
@Override
protected void setupButtons(ViewGroup buttonPanel) {
super.setupButtons(buttonPanel);
if (buttonPanel.getVisibility() == View.GONE) {
buttonPanel.setVisibility(View.INVISIBLE);
}
}
}

View File

@@ -21,6 +21,7 @@
android:layout_height="match_parent">
<ScrollView
android:id="@+id/scrollView"
android:fillViewport="true"
android:layout_width="match_parent"
android:layout_height="match_parent">
<LinearLayout
@@ -33,7 +34,8 @@
android:paddingRight="?dialogPreferredPadding"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:id="@+id/topPanel">
android:id="@+id/topPanel"
android:minHeight="@dimen/dialog_list_padding_top_no_title">
<include android:id="@+id/title_template"
android:layout_width="match_parent"
android:layout_height="wrap_content"
@@ -68,41 +70,33 @@
<!-- Button Panel -->
<FrameLayout
android:id="@+id/buttonPanel"
android:minHeight="@dimen/dialog_list_padding_bottom_no_buttons"
android:layout_weight="1"
android:layout_width="match_parent"
android:layout_height="wrap_content">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:divider="?android:attr/dividerHorizontal"
android:showDividers="beginning"
android:dividerPadding="0dip"
android:orientation="vertical"
android:minHeight="@dimen/alert_dialog_button_bar_height"
android:paddingBottom="?dialogPreferredPadding"
style="?android:attr/buttonBarStyle"
android:layoutDirection="locale"
android:measureWithLargestChild="true">
<Button android:id="@+id/button1"
android:layout_gravity="start"
android:layout_weight="1"
android:layout_marginLeft="?dialogPreferredPadding"
android:layout_marginRight="?dialogPreferredPadding"
style="?android:attr/buttonBarButtonStyle"
android:layout_width="match_parent"
android:layout_height="wrap_content" />
<Button android:id="@+id/button3"
android:layout_gravity="start"
android:layout_weight="1"
android:layout_marginLeft="?dialogPreferredPadding"
android:layout_marginRight="?dialogPreferredPadding"
style="?android:attr/buttonBarButtonStyle"
android:layout_width="match_parent"
android:layout_height="wrap_content" />
<Button android:id="@+id/button2"
android:layout_gravity="start"
android:layout_weight="1"
android:layout_marginLeft="?dialogPreferredPadding"
android:layout_marginRight="?dialogPreferredPadding"
style="?android:attr/buttonBarButtonStyle"
android:layout_width="match_parent"
android:layout_height="wrap_content" />

View File

@@ -20,4 +20,7 @@
<dimen name="list_item_padding_horizontal_material">16dp</dimen>
<dimen name="list_item_padding_start_material">16dp</dimen>
<dimen name="list_item_padding_end_material">16dp</dimen>
<dimen name="dialog_list_padding_top_no_title">8dp</dimen>
<dimen name="dialog_list_padding_bottom_no_buttons">8dp</dimen>
</resources>

View File

@@ -20,4 +20,7 @@
<dimen name="list_item_padding_horizontal_material">@dimen/screen_percentage_15</dimen>
<dimen name="list_item_padding_start_material">@dimen/screen_percentage_15</dimen>
<dimen name="list_item_padding_end_material">@dimen/screen_percentage_10</dimen>
<dimen name="dialog_list_padding_top_no_title">@dimen/screen_percentage_15</dimen>
<dimen name="dialog_list_padding_bottom_no_buttons">@dimen/screen_percentage_15</dimen>
</resources>

View File

@@ -61,8 +61,13 @@ please see styles_device_defaults.xml.
<item name="breakStrategy">balanced</item>
</style>
<style name="Widget.Material.ButtonBar" parent="Widget.Material.BaseButtonBar" />
<!-- Alert dialog button bar button -->
<style name="Widget.Material.Button.ButtonBar.AlertDialog" parent="Widget.Material.Button.Borderless.Small">
<item name="paddingStart">@dimen/list_item_padding_start_material</item>
<item name="paddingEnd">@dimen/list_item_padding_end_material</item>
<item name="drawablePadding">8dp</item>
<item name="gravity">center_vertical|left</item>
<item name="minWidth">64dp</item>
<item name="minHeight">@dimen/alert_dialog_button_bar_height</item>

View File

@@ -543,7 +543,11 @@ please see styles_device_defaults.xml.
<item name="textOff">@string/capital_off</item>
</style>
<style name="Widget.Material.ButtonBar">
<style name="Widget.Material.BaseButtonBar">
<item name="background">?attr/colorBackgroundFloating</item>
</style>
<style name="Widget.Material.ButtonBar" parent="Widget.Material.BaseButtonBar">
<item name="background">@null</item>
</style>