Skip to content

Commit

Permalink
Change padding between Add Search Engine action items.
Browse files Browse the repository at this point in the history
antlam wants 16dp of padding between these and this is the best I could do.
  • Loading branch information
mcomella authored and liuche committed Dec 7, 2017
1 parent b3d955c commit d45c790
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 0 deletions.
3 changes: 3 additions & 0 deletions app/src/main/res/menu/menu_search_engine_manual_add.xml
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,9 @@

<menu xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto">

<!-- We modify the Setting's theme's actionButtonStyle in order to change the padding between
these two items - not great, but it works. Details in @style/SettingsActionButtonStyle. -->
<item android:id="@+id/learn_more"
android:icon="@drawable/ic_menu_info"
android:title="@string/preference_autocomplete_learn_more"
Expand Down
22 changes: 22 additions & 0 deletions app/src/main/res/values/styles.xml
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,28 @@

<style name="SettingsTheme" parent="Theme.AppCompat.NoActionBar">
<item name="colorAccent">@color/colorAccentSettings</item>
<item name="actionButtonStyle">@style/SettingsActionButtonStyle</item>
</style>

<style name="SettingsActionButtonStyle" parent="@style/Widget.AppCompat.ActionButton">
<!-- We want 16dp of padding between (i) and "SAVE" on the "Add search engine" Toolbar.
Unfortunately, this Toolbar is shared across all of settings. Solutions:
1) (Current solution) Change the toolbar styles for all of settings
2) Dynamically change the styles for the Toolbar, in code, for this one Settings screen
3) Provide a unique toolbar for this one Settings screen
I opted for 1) because it's simple (we're pressed for time!) and no other screens have more
than one action button and are affected. This isn't very future proof, however.
We set paddingEnd=12dp to preserve the existing padding of the right-most action menu item to
the edge of the device (12dp) and set paddingStart=4dp to complete the 16dp between views.
We then set minWidth=0dp to avoid it's calculations affecting visible padding.
One concern I have is that paddingStart=4dp will cause the title to get too close to the
action menu items, but testing with German, that doesn't seem to be the case. -->
<item name="android:minWidth">0dp</item>
<item name="android:paddingStart">4dp</item>
<item name="android:paddingEnd">12dp</item>
</style>

<style name="InfoTheme" parent="SettingsTheme">
Expand Down

0 comments on commit d45c790

Please sign in to comment.