0% found this document useful (0 votes)
68 views4 pages

Rainbow Colors

The document describes an Android application that displays the colors of the rainbow (VIBGYOR) in a linear layout. It includes the XML code to create text views for each color with the corresponding background color. It also includes the Java code for the main activity class to set and display the layout. The application successfully displays the rainbow colors in a linear layout as intended.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
68 views4 pages

Rainbow Colors

The document describes an Android application that displays the colors of the rainbow (VIBGYOR) in a linear layout. It includes the XML code to create text views for each color with the corresponding background color. It also includes the Java code for the main activity class to set and display the layout. The application successfully displays the rainbow colors in a linear layout as intended.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 4

RAINBOW COLORS

Aim:
To display VIBGYOR – Rainbow colors in Linear layout.
XML Code:
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:id="@+id/LinearLayout1"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical"
tools:context=".MainActivity" >

<TextView
android:id="@+id/textView1"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_weight="0.14"
android:gravity="center"
android:background="#ee82ee"
android:text="Violet"
android:textAppearance="?android:attr/textAppearanceLarge" />

<TextView
android:id="@+id/textView2"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_weight="0.14"
android:gravity="center"
android:background="#4b0082"
android:text="Indigo"
android:textAppearance="?android:attr/textAppearanceLarge" />

<TextView
android:id="@+id/textView3"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_weight="0.14"
android:gravity="center"
android:background="#00f"
android:text="Blue"
android:textAppearance="?android:attr/textAppearanceLarge" />

<TextView
android:id="@+id/textView4"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_weight="0.14"
android:gravity="center"
android:background="#0f0"
android:text="Green"
android:textAppearance="?android:attr/textAppearanceLarge" />

<TextView
android:id="@+id/textView5"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_weight="0.14"
android:gravity="center"
android:background="#ffff00"
android:text="Yellow"
android:textAppearance="?android:attr/textAppearanceLarge" />

<TextView
android:id="@+id/textView6"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_weight="0.14"
android:gravity="center"
android:background="#ffa500"
android:text="Orange"
android:textAppearance="?android:attr/textAppearanceLarge" />

<TextView
android:id="@+id/textView7"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_weight="0.14"
android:gravity="center"
android:background="#f00"
android:text="Red"
android:textAppearance="?android:attr/textAppearanceLarge" />

</LinearLayout>

Java Code:
package com.example.vibgyor.org;

import android.os.Bundle;

import android.app.Activity;

import android.view.Menu;

public class MainActivity extends Activity {

@Override

protected void onCreate(Bundle savedInstanceState) {

super.onCreate(savedInstanceState);

setContentView(R.layout.activity_main);
}

@Override

public boolean onCreateOptionsMenu(Menu menu) {

// Inflate the menu; this adds items to the action bar if it is present.

getMenuInflater().inflate(R.menu.main, menu);

return true;

Output:

Result:

Thus the above Android application was created and executed successfully.

You might also like