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

Android Lab 7

This document describes two tasks for a visual programming lab. The first task involves writing code to create a dynamic user interface with a yellow button centered in a blue layout. The output shows the button centered as intended. The second task instructs the reader to design an application, but provides no details on the desired application design.

Uploaded by

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

Android Lab 7

This document describes two tasks for a visual programming lab. The first task involves writing code to create a dynamic user interface with a yellow button centered in a blue layout. The output shows the button centered as intended. The second task instructs the reader to design an application, but provides no details on the desired application design.

Uploaded by

Ehab Zaben
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 3

Visual Programming Lab 7 Oraib M Alrashdan

Task 1: Try IT an application using Dynamic UI.


Write this code then show the output.

package com.example.admin.myapplication;

import android.graphics.Color;
import android.support.v7.app.AppCompatActivity;
import android.os.Bundle;
import android.widget.Button;
import android.widget.RelativeLayout;

public class MainActivity extends AppCompatActivity {

@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
Button myButton =new Button(this);
myButton.setText("Press me");
myButton.setBackgroundColor(Color.YELLOW);
RelativeLayout myLayout = new RelativeLayout(this);
myLayout.setBackgroundColor(Color.BLUE);
RelativeLayout.LayoutParams buttonParams = new RelativeLayout.LayoutParams

(RelativeLayout.LayoutParams.WRAP_CONTENT,RelativeLayout.LayoutParams.WRAP_CONTENT);
buttonParams.addRule(RelativeLayout.CENTER_HORIZONTAL);
buttonParams.addRule(RelativeLayout.CENTER_VERTICAL);

myLayout.addView(myButton,buttonParams);
setContentView(myLayout);
}
}

The output :
Visual Programming Lab 7 Oraib M Alrashdan
Visual Programming Lab 7 Oraib M Alrashdan

Task 2:
Write your program to design the following application:

You might also like