APUNTES ANDROID
  • Introducción
  • Apuntes Linux
  • Apuntes Red Team
  • Apuntes Blue Team
  • Apuntes Python
  • Ricardev github
  • Escribiendo tu primera App
    • Instalar Android Studio
    • Proyecto
    • Ejecutar una App
    • Anatomía del Proyecto
      • Gradle scripts
      • AndroidManifest.xml
      • Java
      • Res
    • Componentes de una App
      • Activities
      • Fragments
      • Views y ViewGroups
      • Services
      • Broadcast Receivers
      • Intents
      • Content Provider
      • Widgets
    • Paradigmas de diseño
      • Views
        • Pallete Texts
          • TextView
          • EditText
          • AutoCompleteTextView
        • Pallete Buttons
          • Button
          • ImageButton
          • Chip y ChipGroup
          • RadioButton y RadioGroup
          • CheckBox
          • ToggleButton
          • Switch
          • FloatingActionButton
        • Pallete Widgets
          • ImageView
          • ShapeableImageView
          • WebView
          • VideoView
          • CalendarView
          • ProgressBar
          • SeekBar
          • RatingBar
          • SearchView
          • Divider
        • Custom Views
        • View Binding
      • Jetpack Compose
    • Layouts
      • FrameLayout
      • Linear Layout
      • Relative Layout
      • Constraint Layout
      • Table Layout
      • Grid Layout
    • Containers
      • Spinner
      • RecyclerView
      • CardView
      • ScrollView y HorizontalScrollView
      • ViewPager2
      • AppBarLayout y BottomAppBar
      • NavigationView y BottomNavigationView
      • Toolbar y MaterialToolbar
      • TabLayout y TabItem
      • ViewStub
      • etiquetas <include> y <merge>
Powered by GitBook
On this page
  • DEFINICIÓN
  • USO DESDE XML
  • ATRIBUTOS
  • android:foregroundGravity
  • EJEMPLO
  1. Escribiendo tu primera App
  2. Layouts

FrameLayout

Explicación del concepto de FrameLayout

PreviousLayoutsNextLinear Layout

Last updated 2 years ago

DEFINICIÓN

Hereda de ViewGroup.

Es el Layout más sencillo de todos.

Está concevido para bloquear un area de la pantalla y pintar en la misma un solo item.

Normamente se debe utilizar FrameLayout para pintar un solo hijo, por ese motivo se utiliza cuando vamos a hacer uso de un fragment o de una vista custom.

Cuando se pinta una lista con RecyclerView, la estructura más sencilla es pintar dicha lista dentro de un FrameLayout.

USO DESDE XML

<?xml version="1.0" encoding="utf-8"?>
<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:tools="http://schemas.android.com/tools"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    tools:context=".RecyclerViewActivity">

    <androidx.recyclerview.widget.RecyclerView
        android:id="@+id/rvSilentHill"
        android:layout_width="match_parent"
        android:layout_height="wrap_content" />

</FrameLayout>

ATRIBUTOS

android:foregroundGravity

define la gravedad del drawable que se encuentra en el interior del Frame.

EJEMPLO

Vamos a pintar una imagen en un FrameLayout. No tiene ningún misterio pero se debe de seguir la dinámica del ejemplo en cada una de las entradas:

<?xml version="1.0" encoding="utf-8"?>
<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="match_parent"
    android:layout_height="match_parent">
    <ImageView
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:src="@drawable/im_pyramidhead"

</FrameLayout>
FrameLayout  |  Android DevelopersAndroid Developers
Fuente: developer.android
Resultado
Logo