Reputation: 731
I made a DialogFragment
with a RadioButton
ontop and a ListView
below containing more RadioButton
s. And now I'm just wondering what style the ListView
uses that the RadioButton
s don't look the same as the "stand-alone" one.
Here is a snippet of my dialog.xml
<LinearLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_above="@id/buttonGroup"
android:layout_alignParentTop="true"
android:orientation="vertical">
<RadioButton
android:id="@+id/none"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="@string/none" />
<View
android:layout_width="match_parent"
android:layout_height="1dp"
android:background="@android:color/white" />
<ListView
android:id="@+id/conferences"
android:layout_width="match_parent"
android:layout_height="wrap_content" />
</LinearLayout>
And my list_item.xml that I inflate as the rows in getView
of my ArrayAdapter
:
<?xml version="1.0" encoding="utf-8"?>
<RadioButton xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/conference"
android:layout_width="match_parent"
android:layout_height="wrap_content" />
My AppTheme
is based on "Theme.AppCompat"
. I didn't change any style of a specific item in my View.
The "stand-alone" RadioButton
has a white circle with a blue dot when selected and even has a different style while you press it down. The RadioButton
s in the ListView
are all black with a black dot and don't have a "press-down" style. It would be cool if I wouldn't need to programatically set styles for not checked/"press-down"/checked. I already tried to set 2 base Android themes that had "RadioButton" in their names on the ListView
but nothing changed. Maybe there is a way to get the style of the "stand-alone" RadioButton
and set it in the xml files for the other RadioButton
s?
I would post an image but I'm new here so not already allowed to do this.
Update
I changed my AppTheme to this:
<style name="AppTheme" parent="Theme.AppCompat">
<item name="android:textViewStyle">@style/TextAppearance.AppCompat.Large</item>
<item name="android:radioButtonStyle">@style/RadioButtonStyle</item>
</style>
<style name="RadioButtonStyle">
<item name="android:textAppearance">@style/TextAppearance.AppCompat.Large</item>
</style>
And the RadioButton
s in the ListView
changed but not the "stand-alone" one. When I add the style to the RadioButton
:
<RadioButton
android:id="@+id/none"
style="@style/RadioButtonStyle"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="@string/none" />
the text changes but the RadioButton-circle is still there. For the RadioButton
s in the ListView
the circles are gone...
Upvotes: 0
Views: 1076
Reputation: 2293
Make sure that LayoutInflater
in your Adapter
uses Activity
context and not the application context.
Update:
Please remove android
prefix from your style:
<item name="radioButtonStyle">@style/RadioButtonStyle</item>
And update RadioButtonStyle
as follows:
<style name="RadioButtonStyle" parent="@style/Widget.AppCompat.CompoundButton.RadioButton" />
Upvotes: 3