Can't change Radio Button color on Android

后端 未结 8 1599
忘了有多久
忘了有多久 2021-01-01 23:52

I\'m using Android Studio. I need to change the color of the Radio Button, after changing the Button Tint Color value to the one I need it works on the preview, but whenever

8条回答
  •  隐瞒了意图╮
    2021-01-02 00:00

    I have done this way:

    Screenshot

    activity_main.xml

    
    
    
        
    
    
        
    
    
    

    MainActivity.java

    public class MainActivity extends AppCompatActivity
            implements NavigationView.OnNavigationItemSelectedListener {
    
        @Override
        protected void onCreate(Bundle savedInstanceState) {
            super.onCreate(savedInstanceState);
            setContentView(R.layout.activity_main);
            Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar);
            setSupportActionBar(toolbar);
    
    
            RadioGroup radioGroup = (RadioGroup) findViewById(R.id.radioGroup);
    
            /**
             * First Radio Buttonn
             */
            RadioButton radioButtonAndroid = (RadioButton) getLayoutInflater().inflate(R.layout.custom_radiobutton, null);
            radioButtonAndroid.setText("Hello Android");
            radioGroup.addView(radioButtonAndroid);
    
            /**
             * Second Radio Buttonn
             */
            RadioButton radioButtonIos = (RadioButton) getLayoutInflater().inflate(R.layout.custom_radiobutton, null);
            radioButtonIos.setText("Hello Ios");
            radioGroup.addView(radioButtonIos);
        }
    }
    

    custom_radiobutton.xml

    
    
    
    
    

    Hope this will help you.

提交回复
热议问题