4
I started on Android recently (self-taught) and came across the following situation: support for several screens.
I saw some tutorials and doubts of other people but found nothing to help me with certain aspects.
My doubts are:
For example in the image I have on top 250dp x 250dp (default screen), how can I make the image give to the other layout’s (small, large, xlarge)? I have to resize manually?
Then as I understand it, are there ratios for calculating dp’s for other screens? I am correct?
In the register and enter buttons, are inside a way to help all that to the screen, in case it enlarges or shrinks ? For example, in large there are several screen sizes.
I leave the images below.
If someone could clear up my doubts I would appreciate and indicate me for what I have to research.
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/LinearLayout_Base"
android:orientation="vertical"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="#5E554A">
<LinearLayout
android:orientation="horizontal"
android:minWidth="25px"
android:minHeight="25px"
android:id="@+id/linearLayout_Imagem"
android:background="@android:color/white"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginBottom="0.0dp"
android:weightSum="1"
android:layout_marginLeft="0.0dp">
<ImageView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:id="@+id/imageView_Logo"
android:src="@drawable/LOGO"
android:background="@android:color/background_dark"
android:layout_gravity="top"
android:backgroundTint="#00000000"
android:adjustViewBounds="false"
android:layout_margin="20dp"
android:layout_marginBottom="20.0dp"
android:layout_marginRight="20.0dp" />
</LinearLayout>
<TableRow
android:layout_height="wrap_content"
android:layout_width="fill_parent"
android:gravity="center_horizontal">
<TextView
android:id="@+id/TextView_Bem_vindo"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:textSize="20dp"
android:text="Bem-Vindo"
android:layout_span="3"
android:background="#81BC41"
android:textColor="#5E554A"
android:gravity="center"
android:textAllCaps="false"
android:textStyle="bold" />
</TableRow>
<TableRow
android:minWidth="25px"
android:minHeight="25px"
android:id="@+id/tableRow1"
android:layout_width="match_parent"
android:layout_height="wrap_content">
<Button
android:text="CARTÃO DESPERTAR"
android:id="@+id/button_Cartao_Despertar"
android:layout_weight="1"
android:gravity="center"
android:layout_margin="10dp"
android:padding="10dp"
android:background="#FFFFFF"
android:textColor="#81BC41"
android:layout_height="match_parent"
android:textAlignment="inherit"
android:textSize="18dp" />
<Button
android:text="PRODUTOS"
android:id="@+id/button_Produtos"
android:layout_weight="1"
android:gravity="center"
android:layout_margin="10dp"
android:layout_height="match_parent"
android:padding="20dp"
android:background="#FFFFFF"
android:textSize="18dp"
android:textColor="#81BC41" />
</TableRow>
<TableRow
android:minWidth="25px"
android:minHeight="25px"
android:id="@+id/tableRow2"
android:layout_width="match_parent"
android:layout_height="wrap_content">
<Button
android:textSize="18dp"
android:text="LISTA DE COMPRAS"
android:id="@+id/button_Lista_compras"
android:layout_weight="1"
android:gravity="center"
android:layout_margin="10dp"
android:padding="15dp"
android:background="#FFFFFF"
android:textColor="#81BC41"
android:layout_height="match_parent"
android:textAlignment="inherit" />
<Button
android:text="PROMOÇÕES"
android:id="@+id/button_Promocoes"
android:layout_weight="1"
android:gravity="center"
android:layout_margin="10dp"
android:layout_height="match_parent"
android:padding="15dp"
android:background="#FFFFFF"
android:textColor="#81BC41"
android:textSize="18dp" />
</TableRow>
<TableRow
android:minWidth="25px"
android:minHeight="25px"
android:id="@+id/tableRow4"
android:layout_width="match_parent"
android:layout_height="wrap_content">
<Button
android:text="ESTADO DE ENCOMENDAS"
android:id="@+id/button_Encomendas"
android:layout_weight="1"
android:gravity="center"
android:layout_margin="10dp"
android:padding="15dp"
android:background="#FFFFFF"
android:textColor="#81BC41"
android:layout_height="match_parent"
android:textAlignment="inherit"
android:textSize="18dp" />
</TableRow>
<TableRow
android:minWidth="25px"
android:minHeight="25px"
android:id="@+id/tableRow3"
android:layout_width="match_parent"
android:layout_height="wrap_content">
<Button
android:text="REGISTAR-ME"
android:id="@+id/button_Registo"
android:layout_weight="1"
android:gravity="center"
android:background="#000000"
android:textColor="#81BC41"
android:layout_height="match_parent"
android:textAlignment="inherit"
android:padding="15px"
android:layout_margin="10px"
android:textSize="18dp" />
<Button
android:text="INICIAR SESSÃO"
android:id="@+id/button_Log_In"
android:layout_weight="1"
android:padding="15px"
android:gravity="center"
android:background="#000000"
android:textColor="#81BC41"
android:layout_height="match_parent"
android:textAlignment="inherit"
android:layout_margin="10px"
android:textSize="18dp" />
</TableRow>
</LinearLayout>
It is also worth remembering that in the construction of the layout, determining
LinearLayout
,RelativeLayout
..etc, one can apply some strategies to control this problem, avoiding leaving fixed sizes on the components and just "relating between them".. Sure, but this is a few cases... So you don’t have to replicate the layout over and over again.. This is different from the complexity of youractivity
– Marco Giovanni
It doesn’t always stay that way, some things adapt but not everything, like fonts, etc..
– Catarina Ferreira