From 6c093727dc5ab7b13f142506803b1d98a642c910 Mon Sep 17 00:00:00 2001 From: Maurice Lam Date: Thu, 28 May 2015 12:57:55 -0700 Subject: Center nav bar button icon Center the navigation bar button icon when there is no text label. Bug: 21465490 Change-Id: Ie2d890b29c721f6f2fb0608637b5a76ab389294e --- .../main/src/com/android/setupwizardlib/view/NavigationBar.java | 9 +++++++++ 1 file changed, 9 insertions(+) (limited to 'library/main/src/com/android/setupwizardlib/view') diff --git a/library/main/src/com/android/setupwizardlib/view/NavigationBar.java b/library/main/src/com/android/setupwizardlib/view/NavigationBar.java index bc06976..2386339 100644 --- a/library/main/src/com/android/setupwizardlib/view/NavigationBar.java +++ b/library/main/src/com/android/setupwizardlib/view/NavigationBar.java @@ -23,6 +23,7 @@ import android.graphics.Color; import android.graphics.drawable.Drawable; import android.os.Build.VERSION; import android.os.Build.VERSION_CODES; +import android.text.TextUtils; import android.util.AttributeSet; import android.view.ContextThemeWrapper; import android.view.View; @@ -153,6 +154,14 @@ public class NavigationBar extends LinearLayout implements View.OnClickListener } } } + + @Override + protected void onTextChanged(CharSequence text, int start, int lengthBefore, + int lengthAfter) { + super.onTextChanged(text, start, lengthBefore, lengthAfter); + setCompoundDrawablePadding(TextUtils.isEmpty(text) ? 0 : getResources() + .getDimensionPixelSize(R.dimen.suw_navbar_button_drawable_padding)); + } } } -- cgit v1.2.3