I use AppCompat theme. After migrating to Android Studio 1.1, background color has turned from transparent to gray, and worse, spinners are shown with a white background; since text color also is white, items in the list can't be read.
Is there a way to get the original appearance, ie transparent background, or, at least, where must I set the spinner background color to transparent?
Edited: I have created a basic test app with 2 spinners on a screen. The first spinner is declared inside the activity layout, the second one comes from a separate layout and is inflated inside the activity layout. The two spinner have the same configuration, but they are displayed differently.
[link]http://s15.postimg.org/4y5nwourv/Screenshot_2015_03_12_01_23_14.png
[link]http://s8.postimg.org/ti8x5b4w5/Screenshot_2015_03_12_01_23_26.png
I would like to have the first spinner (the one from the activity layout) to be displayed like the one that is from the inflated layout.
Thanks
Edited: The test app code
Main activity
public class MainActivity extends Activity {
private Spinner spinnerLanguagesLayout, spinnerLanguagesInflated;
public List<String> languages = new ArrayList<String>();
private ArrayAdapter<String> adapterLayoutLanguages, adapterInflateLanguages;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
init();
}
public void init() {
LayoutInflater inflater = (LayoutInflater) getApplicationContext().getSystemService(getApplicationContext().LAYOUT_INFLATER_SERVICE);
LinearLayout linearLayoutInflate = (LinearLayout) this.findViewById(R.id.linearLayoutInflate);
LinearLayout linearLayoutSpinnerLanguage = (LinearLayout) inflater.inflate(R.layout.specific_spinner_language, null, false);
linearLayoutInflate.addView(linearLayoutSpinnerLanguage);
linearLayoutSpinnerLanguage.setLayoutParams(new LinearLayout.LayoutParams(ViewGroup.LayoutParams.WRAP_CONTENT, ViewGroup.LayoutParams.WRAP_CONTENT, Gravity.CENTER_HORIZONTAL));
languages.add("english");
languages.add("chinese");
initSpinnerLayout();
initSpinnerInflate();
}
public void initSpinnerLayout() {
spinnerLanguagesLayout = (Spinner) this.findViewById(R.id.spinnerLanguagesLayout);
adapterLayoutLanguages = new LanguagesListAdapter();
spinnerLanguagesLayout.setAdapter(adapterLayoutLanguages);
}
public void initSpinnerInflate() {
spinnerLanguagesInflated = (Spinner) this.findViewById(R.id.spinnerLanguagesInflated);
adapterInflateLanguages = new LanguagesListAdapter();
spinnerLanguagesInflated.setAdapter(adapterInflateLanguages);
}
public class LanguagesListAdapter extends ArrayAdapter<String> {
public LanguagesListAdapter() {
super (getApplicationContext(), R.layout.layout_spinner, languages);
}
@Override
public View getView(int position, View view, ViewGroup parent) {
if (view == null)
{
LayoutInflater inflater = (LayoutInflater) getApplicationContext().getSystemService(Context.LAYOUT_INFLATER_SERVICE);
view = inflater.inflate(R.layout.layout_spinner, parent, false);
}
final TextView textViewLanguage = (TextView) view.findViewById(R.id.textView);
textViewLanguage.setText(languages.get(position));
return view;
}
@Override
public View getDropDownView(int position, View convertView, ViewGroup parent)
{ // This view starts when we click the spinner.
View row = convertView;
if(row == null)
{
LayoutInflater inflater = (LayoutInflater) getApplicationContext().getSystemService(Context.LAYOUT_INFLATER_SERVICE);
row = inflater.inflate(R.layout.layout_spinner, parent, false);
}
final TextView textViewLanguage = (TextView) row.findViewById(R.id.textView);
textViewLanguage.setText(languages.get(position));
return row;
}
}
}
Main activity layout
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:fluentdroid="http://schemas.android.com/apk/res-auto"
android:orientation="vertical"
android:layout_width="fill_parent"
android:layout_height="fill_parent">
<LinearLayout
android:orientation="vertical"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_weight="1">
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textAppearance="?android:attr/textAppearanceLarge"
android:text="Spinner from activity layout"
android:id="@+id/textView2"
android:layout_gravity="center_horizontal" />
<Spinner
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:id="@+id/spinnerLanguagesLayout"
style="@style/Base.TextAppearance.AppCompat.Large" />
</LinearLayout>
<LinearLayout
android:orientation="horizontal"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_weight="1"></LinearLayout>
<LinearLayout
android:orientation="horizontal"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:id="@+id/linearLayoutInflate"
android:layout_weight="1"></LinearLayout>
<LinearLayout
android:orientation="horizontal"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_weight="1"></LinearLayout>
</LinearLayout>
Inflated spinner layout
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="vertical" android:layout_width="fill_parent"
android:layout_height="wrap_content">
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textAppearance="?android:attr/textAppearanceLarge"
android:text="Spinner from inflated layout"
android:id="@+id/textView3" />
<Spinner
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:id="@+id/spinnerLanguagesInflated"
style="@style/Base.TextAppearance.AppCompat.Large"/>
</LinearLayout>
Spinner item layout
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="fill_parent">
<TextView
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:id="@+id/textView"
android:gravity="center_horizontal"
style="@style/Base.TextAppearance.AppCompat.Large" />
</LinearLayout>