I would like to change the style for one switch button
This is the xml code,
<Switch
android:id="@+id/switch
style="@style/switchStyle"
android:layout_alignParentRight="true"
/>
but I want to do this with code:
Switch newSwitch = new Switch(context);
RelativeLayout.LayoutParams params = new RelativeLayout.LayoutParams(RelativeLayout.LayoutParams.WRAP_CONTENT, RelativeLayout.LayoutParams.WRAP_CONTENT);
params.addRule(RelativeLayout.ALIGN_PARENT_RIGHT);
params.addRule(RelativeLayout.CENTER_VERTICAL);
viewHolder.switchButton = newSwitch;
viewHolder.switchButton.setLayoutParams(params);