LE-Common Widgets 2
LE-Common Widgets 2
OBJECTIVES
• Objectives: Working with common widgets
INSTRUCTIONS
1. Create a new project, and add layouts based on the following hierarchy:
ImageView
Button
▪ XML attributes
Widget/Layout Attributes
LinearLayout layout_width="match_parent"
layout_height="match_parent"
orientation="vertical"
padding="20dp"
ImageView layout_width="wrap_content"
layout_height="wrap_content"
*create an id for the ImageView
Button layout_width="wrap_content"
layout_height="wrap_content"
text="Change Image"
layout_gravity="center_horizontal"
*create an id for the Button
RadioButton
RadioButton
TextView
▪ XML attributes
Widget/Layout Attributes
LinearLayout layout_width="match_parent"
layout_height="match_parent"
orientation="vertical"
padding="16d
RadioGroup layout_width="match_parent"
layout_height="wrap_content"
background="#dbeceb"
padding="15dp"
*create an id for the RadioGroup
RadioButton layout_width="wrap_content"
layout_height="wrap_content"
text="Radio Button 1"
*create an id for the RadioButton
RadioButton layout_width="wrap_content"
layout_height="wrap_content"
text="Radio Button 2"
*create an id for the RadioButton
TextView layout_width="match_parent"
layout_height="wrap_content"
textAlignment="center"
textStyle="bold"
textSize="18dp"
padding="20dp"
*create an id for the TextView
CheckBox
CheckBox
Button
TextView
▪ XML attributes
Widget/Layout Attributes
LinearLayout layout_width="match_parent"
layout_height="match_parent"
orientation="vertical"
padding="16d
CheckBox layout_width="match_parent"
layout_height="wrap_content"
text="Check Box 1"
padding="16dp"
*create an id for the CheckBox
CheckBox layout_width="match_parent"
layout_height="wrap_content"
text="Check Box 2"
padding="16dp"
*create an id for the CheckBox
Button layout_width="wrap_content"
layout_height="wrap_content"
text="Show Text"
layout_gravity="center_horizontal"
*create an id for the Button
TextView layout_width="match_parent"
layout_height="wrap_content"
textAlignment="center"
textStyle="bold"
textSize="18dp"
padding="20dp"
*create an id for the TextView
b. C layout:
override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
………
title = "Demo RadioButton"
binding. <RadioGroup id> .setOnCheckedChangeListener(this)
}
c. D layout
override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
………
title = "Demo CheckBox"