Skip to content

Instantly share code, notes, and snippets.

@MikeySmash
Created May 4, 2019 11:26
Show Gist options
  • Save MikeySmash/076298b7763423623f479aad95b70c0b to your computer and use it in GitHub Desktop.
Save MikeySmash/076298b7763423623f479aad95b70c0b to your computer and use it in GitHub Desktop.
RadioButton changes background color XML
<ScrollView xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical"
tools:context=".MainActivity"
android:background="@color/main_bg">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical">
<RadioGroup
android:id="@+id/q1"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="8dp"
android:orientation="vertical">
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:textSize="18dp"
android:layout_marginTop="8dp"
android:layout_marginRight="16dp"
android:layout_marginLeft="16dp"
android:layout_marginBottom="8dp"
android:textStyle="bold"
android:fontFamily="sans-serif-condensed-medium"
android:textColor="@color/secondaryTextColor"
android:text="Question 1:"/>
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:textSize="18dp"
android:layout_marginTop="8dp"
android:layout_marginRight="16dp"
android:layout_marginLeft="16dp"
android:layout_marginBottom="8dp"
android:textColor="@color/secondaryTextColor"
android:fontFamily="sans-serif-condensed-light"
android:text="What is your name?"/>
<RadioButton
android:id="@+id/q1_answer1"
style="@style/RadioButtonStyle"
android:onClick="onSelect"
android:fontFamily="sans-serif-condensed-light"
android:text="Bob" />
<RadioButton
android:id="@+id/q1_answer2"
style="@style/RadioButtonStyle"
android:onClick="onSelect"
android:fontFamily="sans-serif-condensed-light"
android:text="Billy" />
<RadioButton
android:id="@+id/q1_answer3"
style="@style/RadioButtonStyle"
android:fontFamily="sans-serif-condensed-light"
android:onClick="onSelect"
android:text="Ben" />
<RadioButton
android:id="@+id/q1_answer4"
style="@style/RadioButtonStyle"
android:onClick="onSelect"
android:fontFamily="sans-serif-condensed-light"
android:text="Brian" />
</RadioGroup>
</LinearLayout>
</ScrollView>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment