android为什么我RadioGroup里面放2个RadioButton没问题,放4个就出错

Caused by: android.view.InflateException: Binary XML file line #65: Binary XML file line #65: Error inflating class
Caused by: android.view.InflateException: Binary XML file line #65: Error inflating class
Caused by: java.lang.reflect.InvocationTargetException

 <RadioGroup
        android:id="@+id/main_tab_group"
        android:layout_width="match_parent"
        android:layout_height="60dp"
        android:orientation="horizontal"
        android:layout_alignParentBottom="true"
        android:background="@color/colorPrimary"
        >
        <RadioButton
            android:id="@+id/news"
            style="@style/maintabbutton"
            android:background="@drawable/main_tab_news"
            />
        <RadioButton
            android:id="@+id/topic"
            style="@style/maintabbutton"
            android:background="@drawable/main_tab_topic"/>

        <RadioButton
            android:id="@+id/practice"
            style="@style/maintabbutton"
            android:background="@drawable/main_tab_practice"
            />

        <RadioButton
            android:id="@+id/video"
            style="@style/maintabbutton"
            android:background="@drawable/main_tab_video"/>
 </RadioGroup>
    maintabbutton:
 <style name="maintabbutton">
        <item name="android:layout_weight">1</item>
        <item name="android:layout_height">wrap_content</item>
        <item name="android:gravity">center_horizontal</item>
        <item name="android:button">@null</item>
    </style>

5个我都放过,一点问题没有,下面是布局:

 <RadioGroup
        android:id="@+id/radio_group"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:background="@drawable/bottom_tab_bg"
        android:orientation="horizontal" >

        <RadioButton
            android:id="@+id/rb_home"
            style="@style/ButtonTabStyle"
            android:drawableTop="@drawable/btn_tab_home_selector"
            android:text="@string/radio_button_home" />

        <RadioButton
            android:id="@+id/rb_news"
            style="@style/ButtonTabStyle"
            android:drawableTop="@drawable/btn_tab_news_selector"
            android:text="@string/radio_button_news" />

        <RadioButton
            android:id="@+id/rb_services"
            style="@style/ButtonTabStyle"
            android:drawableTop="@drawable/btn_tab_services_selector"
            android:text="@string/radio_button_smartservice" />

        <RadioButton
            android:id="@+id/rb_govaffairs"
            style="@style/ButtonTabStyle"
            android:drawableTop="@drawable/btn_tab_govaffairs_selector"
            android:text="@string/radio_button_govaffairs" />

        <RadioButton
            android:id="@+id/rb_setting"
            style="@style/ButtonTabStyle"
            android:drawableTop="@drawable/btn_tab_setting_selector"
            android:text="@string/radio_button_setting" />
    </RadioGroup>
 <style name="ButtonTabStyle">
        <item name="android:layout_width">wrap_content</item>
        <item name="android:layout_height">wrap_content</item>
        <item name="android:layout_gravity">center_vertical</item>
        <item name="android:button">@null</item>
        <item name="android:drawablePadding">3dp</item>
        <item name="android:padding">5dp</item>
        <item name="android:textColor">@drawable/btn_tab_text_selector</item>
        <item name="android:layout_weight">1</item>
        <item name="android:gravity">center</item>
    </style>

你的style少了宽度的这个属性wrap_content

布局没错。我复制你的代码过去的,没问题啊,看看drawable资源错没

错误提示里有行数,找到对应行看看。

你的style少了android:layout_width 属性

前两个点击如果没有问题,就是第三个开始出了问题,建议你把跳转界面发出来看下。是不是下个界面出了问题。

我改了几次代码,发现这个问题好像是用了4个selector导致的,我把另外两个button换成和前两个button一样的selector就没问题,但是用的selector数量超过2个,程序就蹦了