Fix the spinner drop-down button

Requires re-theming the Fragment. I feel like there's got to be a better way, but I have no idea what it would be.
This commit is contained in:
Bradlee Speice 2014-12-26 11:11:25 -05:00
parent d49c5e593c
commit c7ee841a9c
3 changed files with 21 additions and 15 deletions

View File

@ -1,10 +1,12 @@
package org.bspeice.minimalbible.activity.downloader; package org.bspeice.minimalbible.activity.downloader;
import android.app.AlertDialog; import android.app.AlertDialog;
import android.content.Context;
import android.content.DialogInterface; import android.content.DialogInterface;
import android.graphics.drawable.Drawable; import android.graphics.drawable.Drawable;
import android.os.Bundle; import android.os.Bundle;
import android.util.Log; import android.util.Log;
import android.view.ContextThemeWrapper;
import android.view.LayoutInflater; import android.view.LayoutInflater;
import android.view.View; import android.view.View;
import android.view.ViewGroup; import android.view.ViewGroup;
@ -88,9 +90,20 @@ public class BookListFragment extends BaseFragment {
@Override @Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, public View onCreateView(LayoutInflater inflater, ViewGroup container,
Bundle savedInstanceState) { Bundle savedInstanceState) {
this.inflater = inflater; /*
View rootView = inflater.inflate(R.layout.fragment_download, container, In order to get the spinner arrow button to have the right color, we need to modify
android:textColorSecondary of the parent theme. For whatever reason, applying this
modification in the XML doesn't work. However, I don't want to have a different theme for
the entire activity, so what the below accomplishes is the same as specifying
android:theme in the AndroidManifest for an activity.
So if you ever change the below code: PLEASE, make sure the language selector colors
are correct.
*/
Context ctx = new ContextThemeWrapper(getActivity(), R.style.MinimalBible_DownloadList);
this.inflater = (LayoutInflater) ctx.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
View rootView = this.inflater.inflate(R.layout.fragment_download, container,
false); false);
ButterKnife.inject(this, rootView); ButterKnife.inject(this, rootView);
displayModules(); displayModules();

View File

@ -7,7 +7,6 @@
<Spinner <Spinner
android:id="@+id/spn_available_languages" android:id="@+id/spn_available_languages"
style="@style/MinimalBible.Spinner"
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:minHeight="?attr/actionBarSize" /> android:minHeight="?attr/actionBarSize" />

View File

@ -42,16 +42,10 @@
<item name="android:textColorSecondary">@color/settingsTextColorSecondary</item> <item name="android:textColorSecondary">@color/settingsTextColorSecondary</item>
</style> </style>
<!-- Clear the background (including the drop-down arrow) for spinners. <!-- Fix the drop-down button for spinners. Please see BookListFragment.onCreateView
Some quick documentation: The spinner is a 9-patch controlled by android:background. for further documentation on how this is used. -->
I have no idea why it's using the "dark" spinner drop-down, as everything points <style name="MinimalBibleBase.DownloadList" parent="MinimalBibleBase">
to it using the light spinner, being that the activity inherits the application theme, <item name="android:textColorSecondary">@color/textColor</item>
and the application theme is light by proxy of MinimalBible -> MinimalBibleBase.
However, when I set the Download activity theme to Light.NoActionBar, the spinner color
corrects itself (while messing up a couple other things).
TODO: Why the heck is the spinner drop-down white? -->
<style name="MinimalBibleBase.Spinner">
<item name="android:background">@android:color/transparent</item>
</style> </style>
<!-- Actual application style. Allows selective over-riding while inheriting <!-- Actual application style. Allows selective over-riding while inheriting
@ -62,7 +56,7 @@
<style name="MinimalBible.NavigationDrawer.Title" parent="MinimalBibleBase.NavigationDrawer.Title" /> <style name="MinimalBible.NavigationDrawer.Title" parent="MinimalBibleBase.NavigationDrawer.Title" />
<style name="MinimalBible.Spinner" parent="MinimalBibleBase.Spinner" /> <style name="MinimalBible.DownloadList" parent="MinimalBibleBase.DownloadList" />
<style name="MinimalBible.Settings" parent="MinimalBibleBase.Settings" /> <style name="MinimalBible.Settings" parent="MinimalBibleBase.Settings" />
</resources> </resources>