From 62b5c029ad6ae0970099056d836a50ff8435d47b Mon Sep 17 00:00:00 2001 From: serso Date: Mon, 9 Feb 2015 16:31:18 +0100 Subject: [PATCH] Fix for ListView padding in PreferenceActivity --- .../preferences/BasePreferencesActivity.java | 19 +++++++++++++++++-- 1 file changed, 17 insertions(+), 2 deletions(-) diff --git a/android-app/src/main/java/org/solovyev/android/calculator/preferences/BasePreferencesActivity.java b/android-app/src/main/java/org/solovyev/android/calculator/preferences/BasePreferencesActivity.java index 5feb35a0..bbba8ac7 100644 --- a/android-app/src/main/java/org/solovyev/android/calculator/preferences/BasePreferencesActivity.java +++ b/android-app/src/main/java/org/solovyev/android/calculator/preferences/BasePreferencesActivity.java @@ -12,6 +12,7 @@ import android.view.ViewGroup; import android.widget.LinearLayout; import android.widget.ListView; import org.solovyev.android.Activities; +import org.solovyev.android.Views; import org.solovyev.android.calculator.*; import org.solovyev.android.checkout.ActivityCheckout; import org.solovyev.android.checkout.Checkout; @@ -47,7 +48,8 @@ public abstract class BasePreferencesActivity extends PreferenceActivity impleme @Override public void setContentView(int layout) { - final ViewGroup contentView = (ViewGroup) LayoutInflater.from(this).inflate(R.layout.cpp_activity_settings, new LinearLayout(this), true); + final LayoutInflater inflater = LayoutInflater.from(this); + final ViewGroup contentView = (ViewGroup) inflater.inflate(R.layout.cpp_activity_settings, new LinearLayout(this), true); actionBar = (Toolbar) contentView.findViewById(R.id.action_bar); actionBar.setNavigationOnClickListener(new View.OnClickListener() { @@ -58,7 +60,20 @@ public abstract class BasePreferencesActivity extends PreferenceActivity impleme }); final ViewGroup contentWrapper = (ViewGroup) contentView.findViewById(R.id.content_wrapper); - LayoutInflater.from(this).inflate(layout, contentWrapper, true); + inflater.inflate(layout, contentWrapper, true); + + // let's fix padding for parent view of list view + Views.processViewsOfType(contentWrapper, ViewGroup.class, new Views.ViewProcessor() { + @Override + public void process(@Nonnull ViewGroup view) { + for (int i = 0; i < view.getChildCount(); i++) { + final View child = view.getChildAt(i); + if (child.getId() == android.R.id.list) { + view.setPadding(0, 0, 0, 0); + } + } + } + }); getWindow().setContentView(contentView); }