Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- Activityl.xml
- <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
- android:layout_width="match_parent"
- android:layout_height="match_parent"
- android:orientation="vertical">
- <LinearLayout
- android:layout_width="match_parent"
- android:layout_height="match_parent"
- android:orientation="vertical"
- android:layout_weight="1"
- android:background="#000fe5"
- android:id="@+id/flag1"/>
- <LinearLayout
- android:layout_width="match_parent"
- android:layout_height="match_parent"
- android:orientation="vertical"
- android:layout_weight="1"
- android:background="#ffffff"
- android:id="@+id/flag2"/>
- <LinearLayout
- android:layout_width="match_parent"
- android:layout_height="match_parent"
- android:orientation="vertical"
- android:layout_weight="1"
- android:background="#000fe6"
- android:id="@+id/flag3"/>
- </LinearLayout>
- ----------------------
- Main activity java
- package com.example.hackeru.myflag;
- import android.graphics.Color;
- import android.support.v7.app.AppCompatActivity;
- import android.os.Bundle;
- import android.widget.LinearLayout;
- public class MainActivity extends AppCompatActivity {
- LinearLayout flag1,flag2,flag3;
- @Override
- protected void onCreate(Bundle savedInstanceState) {
- super.onCreate(savedInstanceState);
- setContentView(R.layout.activity_main);
- setPointer();
- }
- private void setPointer() {
- flag1 = findViewById(R.id.flag1);
- flag2 = findViewById(R.id.flag2);
- flag3 = findViewById(R.id.flag3);
- flag1.setBackgroundColor(Color.RED);
- flag2.setBackgroundColor(Color.YELLOW);
- flag3.setBackgroundColor(Color.RED);
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement