I am using a CheckBox
in my layout which is partly visible.I am including the screenshot.
Below is the layout and java code.
xml:
<android.support.v7.widget.AppCompatCheckBox
android:layout_width="20dp"
android:layout_height="20dp"
android:text="Check box"
android:id="@+id/checkbox"
android:theme="@style/MyCheckBox"
android:layout_marginRight="40dp"
android:layout_marginTop="20dp"
android:layout_alignParentRight="true"
android:layout_alignParentEnd="true" />
java:
checkbox=(AppCompatCheckBox) findViewById(R.id.checkbox);
checkbox.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() {
@Override
public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) {
if(isChecked){
relativeLayout.setVisibility(View.VISIBLE);
}
else {
relativeLayout.setVisibility(View.INVISIBLE);
}
}
});
Screenshot:
Aucun commentaire:
Enregistrer un commentaire