为了方便说明 先上一张图
我想达到的效果是红框里的样子,(注意两行是一个RadioGroup组)并且按钮在一行里也较多,需要包在HorizontalScrollView里,现在的问题是:不互斥了!即:都可以选中,但选择同组中的按钮,之前选中的不取消选择,现在红框外的好使。
然后面我分别只把这段代码和整页的完整代码分别贴出来。
不好使部分的代码
<!--RowStart背景颜色和动态背景-->
<RadioGroup
android:id="@+id/rgTwoRow_background"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="left"
>
<!-- 一行 -->
<LinearLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:orientation="vertical"
>
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textSize="@dimen/titile_textSize"
android:textColor="@color/titile_textColor"
android:text="背景颜色:"/>
<HorizontalScrollView
android:layout_width="wrap_content"
android:layout_height="wrap_content">
<LinearLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:orientation="horizontal">
<RadioButton
android:tag="#ffffff"
android:layout_width="@dimen/button_width"
android:layout_height="@dimen/button_height"
android:layout_marginLeft="@dimen/ColumnWidth"
android:button="@null"
android:background="@drawable/rbtn_ffffff_selector"
/>
<RadioButton
android:tag="#000000"
android:layout_width="@dimen/button_width"
android:layout_height="@dimen/button_height"
android:layout_marginLeft="@dimen/ColumnWidth"
android:button="@null"
android:background="@drawable/rbtn_000000_selector"
/>
<RadioButton
android:tag="#01fe29"
android:layout_width="@dimen/button_width"
android:layout_height="@dimen/button_height"
android:layout_marginLeft="@dimen/ColumnWidth"
android:button="@null"
android:background="@drawable/rbtn_01fe29_selector"
/>
<RadioButton
android:tag="#01fec8"
android:layout_width="@dimen/button_width"
android:layout_height="@dimen/button_height"
android:layout_marginLeft="@dimen/ColumnWidth"
android:button="@null"
android:background="@drawable/rbtn_01fec8_selector"
/>
<RadioButton
android:tag="#019efd"
android:layout_width="@dimen/button_width"
android:layout_height="@dimen/button_height"
android:layout_marginLeft="@dimen/ColumnWidth"
android:button="@null"
android:background="@drawable/rbtn_019efd_selector"/>
<RadioButton
android:tag="#fd006d"
android:layout_width="@dimen/button_width"
android:layout_height="@dimen/button_height"
android:layout_marginLeft="@dimen/ColumnWidth"
android:button="@null"
android:background="@drawable/rbtn_fd006d_selector"/>
<RadioButton
android:tag="#ff0000"
android:layout_width="@dimen/button_width"
android:layout_height="@dimen/button_height"
android:layout_marginLeft="@dimen/ColumnWidth"
android:button="@null"
android:background="@drawable/rbtn_ff0000_selector"/>
<RadioButton
android:tag="#ff010c"
android:layout_width="@dimen/button_width"
android:layout_height="@dimen/button_height"
android:layout_marginLeft="@dimen/ColumnWidth"
android:button="@null"
android:background="@drawable/rbtn_ff010c_selector"/>
<RadioButton
android:tag="#ff5402"
android:layout_width="@dimen/button_width"
android:layout_height="@dimen/button_height"
android:layout_marginLeft="@dimen/ColumnWidth"
android:button="@null"
android:background="@drawable/rbtn_ff5402_selector"/>
<RadioButton
android:tag="#ffe103"
android:layout_width="@dimen/button_width"
android:layout_height="@dimen/button_height"
android:layout_marginLeft="@dimen/ColumnWidth"
android:button="@null"
android:background="@drawable/rbtn_ffe103_selector"/>
</LinearLayout>
</HorizontalScrollView>
</LinearLayout>
<!-- 一行完毕 -->
<!-- 一行 -->
<LinearLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:orientation="vertical"
>
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textSize="@dimen/titile_textSize"
android:textColor="@color/titile_textColor"
android:text="背景颜色:"/>
<HorizontalScrollView
android:layout_width="wrap_content"
android:layout_height="wrap_content">
<LinearLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:orientation="horizontal">
<RadioButton
android:tag="#ffffff"
android:layout_width="@dimen/button_width"
android:layout_height="@dimen/button_height"
android:layout_marginLeft="@dimen/ColumnWidth"
android:button="@null"
android:background="@drawable/rbtn_ffffff_selector"
/>
<RadioButton
android:tag="#000000"
android:layout_width="@dimen/button_width"
android:layout_height="@dimen/button_height"
android:layout_marginLeft="@dimen/ColumnWidth"
android:button="@null"
android:background="@drawable/rbtn_000000_selector"
/>
<RadioButton
android:tag="#01fe29"
android:layout_width="@dimen/button_width"
android:layout_height="@dimen/button_height"
android:layout_marginLeft="@dimen/ColumnWidth"
android:button="@null"
android:background="@drawable/rbtn_01fe29_selector"
/>
<RadioButton
android:tag="#01fec8"
android:layout_width="@dimen/button_width"
android:layout_height="@dimen/button_height"
android:layout_marginLeft="@dimen/ColumnWidth"
android:button="@null"
android:background="@drawable/rbtn_01fec8_selector"
/>
<RadioButton
android:tag="#019efd"
android:layout_width="@dimen/button_width"
android:layout_height="@dimen/button_height"
android:layout_marginLeft="@dimen/ColumnWidth"
android:button="@null"
android:background="@drawable/rbtn_019efd_selector"/>
<RadioButton
android:tag="#fd006d"
android:layout_width="@dimen/button_width"
android:layout_height="@dimen/button_height"
android:layout_marginLeft="@dimen/ColumnWidth"
android:button="@null"
android:background="@drawable/rbtn_fd006d_selector"/>
<RadioButton
android:tag="#ff0000"
android:layout_width="@dimen/button_width"
android:layout_height="@dimen/button_height"
android:layout_marginLeft="@dimen/ColumnWidth"
android:button="@null"
android:background="@drawable/rbtn_ff0000_selector"/>
<RadioButton
android:tag="#ff010c"
android:layout_width="@dimen/button_width"
android:layout_height="@dimen/button_height"
android:layout_marginLeft="@dimen/ColumnWidth"
android:button="@null"
android:background="@drawable/rbtn_ff010c_selector"/>
<RadioButton
android:tag="#ff5402"
android:layout_width="@dimen/button_width"
android:layout_height="@dimen/button_height"
android:layout_marginLeft="@dimen/ColumnWidth"
android:button="@null"
android:background="@drawable/rbtn_ff5402_selector"/>
<RadioButton
android:tag="#ffe103"
android:layout_width="@dimen/button_width"
android:layout_height="@dimen/button_height"
android:layout_marginLeft="@dimen/ColumnWidth"
android:button="@null"
android:background="@drawable/rbtn_ffe103_selector"/>
</LinearLayout>
</HorizontalScrollView>
</LinearLayout>
<!-- 一行完毕 -->
</RadioGroup>
<!-- RowEnd背景颜色和动态背景-->