Upgrade to Pro — share decks privately, control downloads, hide ads and more …

Google Android - Aula 3 - Turma 2015.1

Google Android - Aula 3 - Turma 2015.1

Slides do curso "Desenvolvimento Google Android", aula 3, ministrado na Linux Fi (turma 2015.1).

Eduardo Carneiro

June 27, 2015
Tweet

More Decks by Eduardo Carneiro

Other Decks in Programming

Transcript

  1. 64 TableLayout <TableLayout xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="match_parent" android:layout_height="match_parent" android:stretchColumns="1,3"> <TableRow> <TextView android:layout_height="wrap_content"

    android:layout_width="wrap_content" android:text="Nome:"/> <EditText android:layout_height="wrap_content" android:layout_width="match_parent" android:layout_span="3"/> </TableRow> <TableRow> <TextView android:layout_height="wrap_content" android:layout_width="wrap_content" android:text="Telefone:"/> <EditText android:layout_height="wrap_content" android:layout_width="wrap_content"/> <TextView android:layout_height="wrap_content" android:layout_width="wrap_content" android:text="CEP:"/> <EditText android:layout_height="wrap_content" android:layout_width="wrap_content"/> </TableRow> </TableLayout> <TableLayout xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="match_parent" android:layout_height="match_parent" android:stretchColumns="1,3"> <TableRow> <TextView android:layout_height="wrap_content" android:layout_width="wrap_content" android:text="Nome:"/> <EditText android:layout_height="wrap_content" android:layout_width="match_parent" android:layout_span="3"/> </TableRow> <TableRow> <TextView android:layout_height="wrap_content" android:layout_width="wrap_content" android:text="Telefone:"/> <EditText android:layout_height="wrap_content" android:layout_width="wrap_content"/> <TextView android:layout_height="wrap_content" android:layout_width="wrap_content" android:text="CEP:"/> <EditText android:layout_height="wrap_content" android:layout_width="wrap_content"/> </TableRow> </TableLayout>
  2. 65 GridLayout <GridLayout xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="match_parent" android:layout_height="wrap_content" android:columnCount="3" android:rowCount="2"> <Button android:layout_width="wrap_content"

    android:layout_height="wrap_content" android:text="BOTÃO 1"/> <Button android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_gravity="fill_horizontal" android:text="BOTÃO 2"/> <Button android:layout_width="wrap_content" android:layout_height="wrap_content" android:text="BOTÃO 4" android:layout_rowSpan="2" android:layout_gravity="fill_vertical"/> <Button android:layout_width="wrap_content" android:layout_height="wrap_content" android:text="BOTÃO 3" android:layout_columnSpan="2" android:layout_gravity="fill_horizontal"/> </GridLayout> <GridLayout xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="match_parent" android:layout_height="wrap_content" android:columnCount="3" android:rowCount="2"> <Button android:layout_width="wrap_content" android:layout_height="wrap_content" android:text="BOTÃO 1"/> <Button android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_gravity="fill_horizontal" android:text="BOTÃO 2"/> <Button android:layout_width="wrap_content" android:layout_height="wrap_content" android:text="BOTÃO 4" android:layout_rowSpan="2" android:layout_gravity="fill_vertical"/> <Button android:layout_width="wrap_content" android:layout_height="wrap_content" android:text="BOTÃO 3" android:layout_columnSpan="2" android:layout_gravity="fill_horizontal"/> </GridLayout>
  3. 66 ScrollView <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" android:orientation="vertical" android:layout_width="match_parent" android:layout_height="match_parent"> <ScrollView android:layout_width="match_parent" android:layout_height="match_parent">

    <HorizontalScrollView android:layout_width="match_parent" android:layout_height="match_parent"> <ImageView android:layout_width="wrap_content" android:layout_height="wrap_content" android:src="@drawable/paisagem"/> </HorizontalScrollView> </ScrollView> </LinearLayout> <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" android:orientation="vertical" android:layout_width="match_parent" android:layout_height="match_parent"> <ScrollView android:layout_width="match_parent" android:layout_height="match_parent"> <HorizontalScrollView android:layout_width="match_parent" android:layout_height="match_parent"> <ImageView android:layout_width="wrap_content" android:layout_height="wrap_content" android:src="@drawable/paisagem"/> </HorizontalScrollView> </ScrollView> </LinearLayout>
  4. 67 Include <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" android:orientation="horizontal" android:layout_width="match_parent" android:layout_height="wrap_content" android:background="#cccccc"> <Button android:id="@+id/btAnterior"

    android:layout_width="wrap_content" android:layout_height="wrap_content" android:text="Anterior"/> <LinearLayout android:layout_width="match_parent" android:layout_height="wrap_content" android:gravity="right"> <Button android:id="@+id/btProxima" android:layout_width="wrap_content" android:layout_height="wrap_content" android:text="Próximo"/> <Button android:id="@+id/btConcluir" android:layout_width="wrap_content" android:layout_height="wrap_content" android:text="Concluir"/> </LinearLayout> </LinearLayout> <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" android:orientation="horizontal" android:layout_width="match_parent" android:layout_height="wrap_content" android:background="#cccccc"> <Button android:id="@+id/btAnterior" android:layout_width="wrap_content" android:layout_height="wrap_content" android:text="Anterior"/> <LinearLayout android:layout_width="match_parent" android:layout_height="wrap_content" android:gravity="right"> <Button android:id="@+id/btProxima" android:layout_width="wrap_content" android:layout_height="wrap_content" android:text="Próximo"/> <Button android:id="@+id/btConcluir" android:layout_width="wrap_content" android:layout_height="wrap_content" android:text="Concluir"/> </LinearLayout> </LinearLayout> <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" android:orientation="vertical" android:layout_width="match_parent" android:layout_height="match_parent"> <EditText android:layout_width="match_parent" android:layout_height="0dp" android:layout_weight="1"/> <include android:layout_width="match_parent" android:layout_height="wrap_content" layout="@layout/botoes"/> </LinearLayout> <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" android:orientation="vertical" android:layout_width="match_parent" android:layout_height="match_parent"> <EditText android:layout_width="match_parent" android:layout_height="0dp" android:layout_weight="1"/> <include android:layout_width="match_parent" android:layout_height="wrap_content" layout="@layout/botoes"/> </LinearLayout>
  5. 68 Layout Inflater Permite inflar um arquivo de layout em

    um objeto da classe android.view.View e atribuí-lo a um gerenciador de layout (opcional). LayoutInflater inflater1 = activity.getLayoutInflater(); LayoutInflater inflater2 = LayoutInflater.from(context); View view1 = inflater1.inflate(R.layout.botoes, null); View view2 = inflater2.inflate(R.layout.botoes, null); LayoutInflater inflater1 = activity.getLayoutInflater(); LayoutInflater inflater2 = LayoutInflater.from(context); View view1 = inflater1.inflate(R.layout.botoes, null); View view2 = inflater2.inflate(R.layout.botoes, null);
  6. 69 TextView <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" android:orientation="vertical" android:layout_width="match_parent" android:layout_height="match_parent" android:gravity="center"> <TextView android:layout_width="wrap_content"

    android:layout_height="wrap_content" android:text="Exemplo de TextView www.google.com.br 32333352" android:hint="TextView" android:drawableTop="@drawable/ual" android:drawablePadding="10dp" android:singleLine="true" android:ellipsize="end" android:autoLink="all"/> </LinearLayout> <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" android:orientation="vertical" android:layout_width="match_parent" android:layout_height="match_parent" android:gravity="center"> <TextView android:layout_width="wrap_content" android:layout_height="wrap_content" android:text="Exemplo de TextView www.google.com.br 32333352" android:hint="TextView" android:drawableTop="@drawable/ual" android:drawablePadding="10dp" android:singleLine="true" android:ellipsize="end" android:autoLink="all"/> </LinearLayout>
  7. 70 EditText <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" android:orientation="vertical" android:layout_width="match_parent" android:layout_height="match_parent" android:gravity="center"> <EditText android:layout_width="match_parent"

    android:layout_height="wrap_content" android:drawableRight="@drawable/tap" android:drawablePadding="10dp" android:hint="EditText" android:inputType="number" android:imeOptions="actionSearch" android:imeActionLabel="Buscar"/> </LinearLayout> <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" android:orientation="vertical" android:layout_width="match_parent" android:layout_height="match_parent" android:gravity="center"> <EditText android:layout_width="match_parent" android:layout_height="wrap_content" android:drawableRight="@drawable/tap" android:drawablePadding="10dp" android:hint="EditText" android:inputType="number" android:imeOptions="actionSearch" android:imeActionLabel="Buscar"/> </LinearLayout>
  8. 71 Outros componentes <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" android:orientation="vertical" android:layout_width="match_parent" android:layout_height="match_parent" android:gravity="center"> <Button

    android:layout_width="wrap_content" android:layout_height="wrap_content" android:text="Button" android:drawableLeft="@drawable/tam" android:drawablePadding="10dp"/> <ImageButton android:layout_width="wrap_content" android:layout_height="wrap_content" android:src="@drawable/thy" android:background="@android:color/transparent"/> <ToggleButton android:layout_width="wrap_content" android:layout_height="wrap_content" android:textOn="ToggleButton ON" android:textOff="ToggleButton OFF" android:checked="true"/> <Switch android:layout_width="wrap_content" android:layout_height="wrap_content" android:textOn="Switch ON" android:textOff="Switch OFF" android:checked="true"/> ... <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" android:orientation="vertical" android:layout_width="match_parent" android:layout_height="match_parent" android:gravity="center"> <Button android:layout_width="wrap_content" android:layout_height="wrap_content" android:text="Button" android:drawableLeft="@drawable/tam" android:drawablePadding="10dp"/> <ImageButton android:layout_width="wrap_content" android:layout_height="wrap_content" android:src="@drawable/thy" android:background="@android:color/transparent"/> <ToggleButton android:layout_width="wrap_content" android:layout_height="wrap_content" android:textOn="ToggleButton ON" android:textOff="ToggleButton OFF" android:checked="true"/> <Switch android:layout_width="wrap_content" android:layout_height="wrap_content" android:textOn="Switch ON" android:textOff="Switch OFF" android:checked="true"/> ...
  9. 72 Outros componentes ... <CheckBox android:layout_width="wrap_content" android:layout_height="wrap_content" android:text="CheckBox" android:checked="true"/> <RadioGroup

    android:layout_width="wrap_content" android:layout_height="wrap_content" android:orientation="horizontal"> <RadioButton android:layout_width="wrap_content" android:layout_height="wrap_content" android:text="RadioButton 1" android:checked="true"/> <RadioButton android:layout_width="wrap_content" android:layout_height="wrap_content" android:text="RadioButton 2"/> </RadioGroup> <SeekBar android:layout_width="match_parent" android:layout_height="wrap_content" android:progress="50" android:max="100" /> <Spinner android:layout_width="wrap_content" android:layout_height="wrap_content" android:background="@android:drawable/btn_dropdown" android:entries="@array/situacoes_chegada_voo_array"/> <ProgressBar android:layout_width="wrap_content" android:layout_height="wrap_content" android:indeterminate="true" style="@android:style/Widget.ProgressBar.Small"/> </LinearLayout> ... <CheckBox android:layout_width="wrap_content" android:layout_height="wrap_content" android:text="CheckBox" android:checked="true"/> <RadioGroup android:layout_width="wrap_content" android:layout_height="wrap_content" android:orientation="horizontal"> <RadioButton android:layout_width="wrap_content" android:layout_height="wrap_content" android:text="RadioButton 1" android:checked="true"/> <RadioButton android:layout_width="wrap_content" android:layout_height="wrap_content" android:text="RadioButton 2"/> </RadioGroup> <SeekBar android:layout_width="match_parent" android:layout_height="wrap_content" android:progress="50" android:max="100" /> <Spinner android:layout_width="wrap_content" android:layout_height="wrap_content" android:background="@android:drawable/btn_dropdown" android:entries="@array/situacoes_chegada_voo_array"/> <ProgressBar android:layout_width="wrap_content" android:layout_height="wrap_content" android:indeterminate="true" style="@android:style/Widget.ProgressBar.Small"/> </LinearLayout>
  10. 73 AlertDialog AlertDialog dialog = new AlertDialog.Builder(this) .setTitle("Pick a color")

    .setItems(R.array.colors_array, new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int which) { } }).create(); dialog.show(); AlertDialog dialog = new AlertDialog.Builder(this) .setTitle("Pick a color") .setItems(R.array.colors_array, new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int which) { } }).create(); dialog.show();