Disposición de Android: coloca una vista entre dos vistas
Estoy tratando de hacer una pantalla, preferiblemente con sólo XML, para que parezca esto:
He seguido este enfoque, pero usando FrameLayout sólo tengo la opción de colocar la vista "naranja" usando layout_gravity
, y como trato de explicar en la imagen, no sé la altura de los diseños, porque ambos miden con layout_weight.
- División de XML en varios archivos xml
- El contenido de los elementos debe consistir en datos de caracteres bien formados o marcado. AndroidManifest.xml
- ¿Cómo ocultar por programación algunos elementos de la vista, pero no todos, en una salida XML?
- Android Cómo agregar icono en cada elemento de la lista listvIew y cambiar el color del texto, Color de fondo
- app falla cuando cambio el orden de mi XML RelativeLayout android
Mi diseño:
<?xml version="1.0" encoding="utf-8"?> <LinearLayout 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" android:orientation="vertical" tools:context="onit.radiolisten.MainActivity"> <FrameLayout android:id="@+id/layout_container_activity_main" android:layout_width="match_parent" android:layout_height="match_parent"> <LinearLayout android:layout_width="match_parent" android:layout_height="match_parent" android:orientation="vertical"> <!-- TOP LAYOUT, THE GREEN ONE ON THE IMAGE --> <LinearLayout android:id="@+id/layout_top_activity_main" android:layout_width="match_parent" android:layout_height="0dip" android:layout_weight="2" android:background="@color/colorPrimary" android:orientation="vertical"></LinearLayout> <!-- BOTTOM LAYOUT, THE BLUE ONE ON THE IMAGE --> <RelativeLayout android:layout_width="match_parent" android:layout_height="0dp" android:layout_weight="1" android:background="#e6e6e6"> </RelativeLayout> </LinearLayout> <!-- THIS IS THE IMAGE I WANT TO POSITION --> <ImageView android:id="@+id/btn_play_radio" android:layout_width="120dp" android:layout_height="120dp" android:layout_gravity="center" android:src="@drawable/play_icon" /> </FrameLayout> </LinearLayout>
¿Puede hacerse esto solo con XML?
- Todos los iconos de ActionMode Bar no se muestran en Android?
- Analizar xml de la respuesta httppost
- InflateException: Línea de archivo XML binario # 22: Error al inflar la clase <unknown>
- Error: (27) No se encontró ningún identificador de recurso para el atributo 'srcCompat' en el paquete 'com.example.jaisonjoseph.newsclient'
- Comentar en el archivo de diseño de Android
- Cómo cambiar el ancho de SwitchCompat thumb
- Android: Cómo crear CursorAdapter desde los datos en un archivo XML
- Uso de la fuente personalizada en Android TextView utilizando xml
<?xml version="1.0" encoding="UTF-8"?> <RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="match_parent" android:layout_height="match_parent"> <--main layout--> <LinearLayout android:layout_width="match_parent" android:layout_height="match_parent" android:orientation="vertical"> <--top layout--> <LinearLayout android:layout_width="match_parent" android:layout_height="0dp" android:layout_marginTop="20dp" android:layout_weight="0.4" android:gravity="bottom|center"/> <LinearLayout android:layout_width="match_parent" android:layout_height="0dp" android:layout_weight="0.1" android:background="@color/callingscreen_color" android:gravity="center|top" /> </LinearLayout> <--layout for img--> <LinearLayout android:layout_width="match_parent" android:layout_height="match_parent" android:orientation="vertical"> <LinearLayout android:layout_width="match_parent" android:layout_height="0dp" android:layout_weight="1.5" > </LinearLayout> <LinearLayout android:layout_width="match_parent" android:layout_height="0dp" android:layout_weight="0.5" android:gravity="center|top"> <--IMage u want to put--> <ImageView android:id="@+id/ivimg" android:layout_width="wrap_content" android:layout_height="wrap_content" android:src="@drawable/img"/> </LinearLayout> </LinearLayout> </RelativeLayout>