Write a Program to create 2 buttons and on the click of the button it should display which button is pressed

 



XML Code:

<?xml version="1.0" encoding="utf-8"?>

<androidx.constraintlayout.widget.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android"   xmlns:app="http://schemas.android.com/apk/res-auto"    xmlns:tools="http://schemas.android.com/tools"

    android:layout_width="match_parent"

    android:layout_height="match_parent"

    tools:context=".MainActivity"

    android:background="#FF00BCD4">

    <Button

        android:id="@+id/print"

        android:layout_width="200dp"        android:layout_height="wrap_content"

        android:background="#ffffff"        android:drawableLeft="@drawable/pinterest"

        android:elevation="20dp"

        android:fontFamily="cursive"

        android:text="Pinterest"

        android:textAlignment="center"

        android:textColor="#f00"

        android:textSize="20dp"

        android:textStyle="bold"       app:layout_constraintBottom_toBottomOf="parent"        app:layout_constraintEnd_toEndOf="parent"        app:layout_constraintHorizontal_bias="0.497"        app:layout_constraintStart_toStartOf="parent"        app:layout_constraintTop_toTopOf="parent"        app:layout_constraintVertical_bias="0.325" />

    <Button

        android:id="@+id/bts"

        android:layout_width="200dp"

   android:layout_height="wrap_content"

        android:background="#ffffff"

   android:drawableLeft="@drawable/bts"

        android:elevation="20dp"

        android:fontFamily="casual"

        android:text="BTS"

        android:textAlignment="center"

        android:textColor="#000"

        android:textSize="25dp"

        android:textStyle="bold"        app:layout_constraintBottom_toBottomOf="parent"        app:layout_constraintEnd_toEndOf="@+id/print"        app:layout_constraintStart_toStartOf="@+id/print"      app:layout_constraintTop_toBottomOf="@+id/print"      app:layout_constraintVertical_bias="0.131" />

</androidx.constraintlayout.widget.ConstraintLayout> 

Output:

 


Comments

Popular posts from this blog

Write a program to create a first display screen on any search engine using auto complete text View

Write a Program to create a toggle button to display the ON/OFF Bluetooth on the display screen.

Write a program to create a login form for social networking website.