0% found this document useful (0 votes)
2 views3 pages

FontColor Size Program

The document outlines the creation of a simple Android application featuring a graphical user interface with components such as TextView and Buttons. The application allows users to change the font size and color of the displayed text through button clicks. The implementation includes XML layout for the interface and Java code for functionality in the MainActivity class.

Uploaded by

23p61a6248
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOC, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
2 views3 pages

FontColor Size Program

The document outlines the creation of a simple Android application featuring a graphical user interface with components such as TextView and Buttons. The application allows users to change the font size and color of the displayed text through button clicks. The implementation includes XML layout for the interface and Java code for functionality in the MainActivity class.

Uploaded by

23p61a6248
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOC, PDF, TXT or read online on Scribd

Aim: Create a simple Android Application that uses GUI components, Font

and Colors.
activity_main.xml
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout
xmlns:android="[Link]
android:orientation="vertical"
android:layout_width="match_parent"
android:layout_height="match_parent">
<TextView
android:id="@+id/textView" android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_margin="30dp"
android:gravity="center"
android:text="Hello World!"
android:textSize="25sp"
android:textStyle="bold" />
<Button
android:id="@+id/button1"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_margin="20dp"
android:gravity="center"
android:text="@string/change_font_size"
android:textSize="25sp" />
<Button
android:id="@+id/button2"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_margin="20dp"
android:gravity="center"
android:text="@string/change_color"
android:textSize="25sp" />
</LinearLayout>

[Link]
package [Link];
import [Link];
import [Link];
import [Link];
import [Link];
import [Link];
import [Link];

public class MainActivity extends AppCompatActivity


{
int ch=1;
float font=30;
@SuppressLint("SetTextI18n")
@Override
protected void onCreate(Bundle savedInstanceState)
{
[Link](savedInstanceState);
setContentView([Link].activity_main);
final TextView t= findViewById([Link]);
Button b1= findViewById([Link].button1);
[Link]("Change Font Size");
[Link](v -> {
[Link](font);
font = font + 5;
if (font == 50)
font = 30;
});
Button b2= findViewById([Link].button2);
[Link]("Change Font Color");
[Link](v ->
{
switch (ch)
{
case 1:
[Link]([Link]);
break;
case 2:
[Link]([Link]);
break;
case 3:
[Link]([Link]);
break;
case 4:
[Link]([Link]);
break;
case 5:
[Link]([Link]);
break;
case 6:
[Link]([Link]);
break;
}
ch++;
if (ch == 7)
ch = 1;
});
}
}

OUTPUT

You might also like