Per prima cosa ci dirigiamo nell Activity main e iniziamo a creare la parte grafica,per la creazione della calcolatrice ho deciso di inserire i tasti dei numeri,quelle delle varie operazioni e un tasto cancella.
Andiamo in alto a sinistra e ci dirigiamo su "split", qui inizieremo la nostra programmazione.
Digitiamo il comando <<LinearLayout per creare appunto un campo lineare nella quale aggiungeremo i nostri bottoni,dopo fatto questo inseriamo un botton che andremo a programmare.
<Button
android:id="@+id/bottoneCancella"
style="@style/Widget.MaterialComponents.ExtendedFloatingActionButton"
android:layout_width="72dp"
android:layout_height="72dp"
android:layout_margin="12dp"
android:text="C"
android:textColor="@color/white"
android:backgroundTint="#ffa500"
android:textSize="32dp"
app:cornerRadius="36dp" />
Questo è il comando per la creazione di un bottone:
all'interno del nostro bottone abbiamo molti attribbuti:
-come prima cosa lo stile del nostro bottone quindi se deve essere rotondo,triangolare o di altri tipi,
-dopo di che abbiamo inserito l'altezza e la larghezza del nostro bottone(sotto forma di dp)
Dopo aver fatto fatto ciò, chiudiamo il tag aperto del layout, e copiamo l'intero contenuto, compreso i bottoni che andremo a incollare come fatto con i bottoni, in modo tale avremo creato tutti i bottoni necessari.
COSA MOLTO IMPORTANTE
Ogni bottone è formato da ud che ci serve per richiamare e utilizzare il file, Quindi dopo aver incollato i bottoni bisogna cambiargli l'id e ovviamente il loro contenuto altrimenti il bottone non verrà letto, ogni bottone deve avere un id diverso, altrimenti vi darà il seguente messaggio di errore:
IL BOTTONE CHE HAI INSERITO E' GIA' ESISTENTE
First we head into the mainActivity and start creating the graphical part,for the creation of the calculator I decided to insert the buttons of the numbers,those of the various operations and a delete button.
We go to the top left and head to "split",here we will start our programming.
We type the command <<LinearLayout to create precisely a linear field in which we will add our buttons,after this is done we insert a button that we are going to program.
<Button
android:id="@+id/buttonDelete"
style="@style/Widget.MaterialComponents.ExtendedFloatingActionButton"
android:layout_width="72dp"
android:layout_height="72dp"
android:layout_margin="12dp"
android:text="C"
android:textColor="@color/white"
android:backgroundTint="#ffa500"
android:textSize="32dp"
app:cornerRadius="36dp" />
This is the command for creating a button:
inside our button we have many attribbuti:
-first the style of our button so if it should be round,triangular or other type,
-after that we entered the height and width of our button(in the form of dp)
After we have done that, we close the open layout tag, and copy the entire contents, including the buttons that we are going to paste as we did with the buttons, so that we will have created all the buttons we need.
VERY IMPORTANT THING
Each button consists of ud that we need to call and use the file, So after pasting the buttons we need to change their id and obviously their content otherwise the button will not be read, each button must have a different id, otherwise it will give you the following error message:
THE BUTTON YOU ENTERED IS ALREADY EXISTING
@tipu curate
Upvoted 👌 (Mana: 15/45) Liquid rewards.
grazie mille!!