> For the complete documentation index, see [llms.txt](https://salvatore-academy.gitbook.io/dev-android-nativo/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://salvatore-academy.gitbook.io/dev-android-nativo/nivel-02-estagio-1/fase-02-primeiro-app-nativo/aula-02-explorando-a-ui-do-android.md).

# \[Aula 02] Explorando a Interface do Usuário (UI) do Android

## Agenda:

* Compreendendo a relação entre UI e UX no Android.
* Decifrando o XML: a linguagem por trás dos designs.
* Os blocos de construção da UI: botões, campos de texto e imagens.
* Entendendo os layouts e como organizam seus elementos.
* Dando vida aos elementos: adicionando interatividade.

{% embed url="<https://youtu.be/WGR76qzTV6c>" %}

## 1. Introdução à UI no desenvolvimento Android

* **O que é UI?** UI, ou Interface do Usuário, refere-se aos pontos de interação entre o usuário e um dispositivo, como botões, barras de progresso e sliders.
* **UI vs UX:** Enquanto UI foca na interface, UX, ou Experiência do Usuário, refere-se à experiência total que um usuário tem ao interagir com um produto.

{% hint style="info" %}
Um bom design de UI é intuitivo e fácil de usar, enquanto uma boa UX faz o usuário sentir-se satisfeito e realizado com a interação total.
{% endhint %}

## 2. Conhecendo o XML e sua relação com a interface

* **O que é XML?** XML é uma linguagem de marcação usada para descrever a estrutura dos dados. No Android, usamos XML para definir layouts.
* **activity\_main.xml:** Este arquivo, que você explorou na aula anterior, é escrito em XML.

{% hint style="warning" %}
XML é sensível ao caso! Tenha certeza de que está usando a capitalização correta para seus elementos e atributos.
{% endhint %}

## 3. Design básico: botões, textos e imagens

* **Botões (`Button`):** Elementos clicáveis que realizam uma ação.
* **Campos de Texto (`EditText`):** Permita que os usuários insiram texto.
* **Imagens (`ImageView`):** Mostra imagens na sua aplicação.

{% hint style="info" %}
Dica: Use o atributo \`android:onClick\` em um botão para especificar a função que será chamada quando o botão for pressionado.
{% endhint %}

## 4. Layouts no Android: Linear, Relative e Constraint

* **Linear Layout:** Organiza os elementos em uma linha ou coluna.
* **Relative Layout:** Organiza os elementos em relação uns aos outros ou ao pai.
* **Constraint Layout:** É o layout mais flexível e poderoso, permitindo que você crie interfaces complexas sem aninhar vários grupos.

{% hint style="success" %}
Constraint Layout é altamente recomendado para designs modernos devido à sua flexibilidade e otimização de desempenho.
{% endhint %}


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation by asking a question.

Perform an HTTP GET request on the following URL with the `ask` and `goal` query parameters:

```
GET https://salvatore-academy.gitbook.io/dev-android-nativo/nivel-02-estagio-1/fase-02-primeiro-app-nativo/aula-02-explorando-a-ui-do-android.md?ask=<question>&goal=<user_goal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is what the user is ultimately trying to achieve, the reason they need the answer. Sharing it helps GitBook give you a better, more relevant answer. A goal is most helpful when it describes the outcome the user wants rather than restating the question. For example, with `ask=how do I create an API token`, a goal like `automate deployments from our CI pipeline` lets GitBook tailor the answer to that use case.

The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
