高度为0dp的MapView不显示

时间:2018-06-15 07:34:52

标签: android height show android-mapview android-constraintlayout

我在活动的片段上有一个mapview,它有一个约束布局。我需要它来适应片段中的其余空间,所以我使用“0dp”高度。

问题是它没有显示,但如果我给它一个固定的高度,如“150dp”,它显示正确。

可能是什么问题?感谢

     @Override
public View onCreateView(LayoutInflater inflater, ViewGroup container,
                         Bundle savedInstanceState) {
    View view = inflater.inflate(R.layout.fragment_inicio, container, false);

    // Asignacion layout.
    asignaComponentes(view);
    asignaTipoLetra();

    fragmentoPadre = container;

    inicializaCups();

    actualizaTablaUltimosConsumos();

    mapView.onCreate(savedInstanceState);
    mapView.getMapAsync(this);
    actualizaMapa();

    return view;
} 

     @Override
public void onMapReady(GoogleMap gmap) {
    map = gmap;
    setUpMap(null);
}

public void setUpMap(Cups cupsMapa){
    map.setMapType(GoogleMap.MAP_TYPE_NORMAL);
}

@Override
public void onResume() {
    mapView.onResume();
    super.onResume();

}

@Override
public void onDestroy() {
    super.onDestroy();
    mapView.onDestroy();
}

@Override
public void onLowMemory() {
    super.onLowMemory();
    mapView.onLowMemory();
}

这是带有Constraint布局的XML Capture of XML

    <?xml version="1.0" encoding="utf-8"?>
    <android.support.constraint.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="@color/colorGrisClaroViesgo"
tools:context="viesgo.cic.es.appconsumidores.inicio.Inicio">

    <android.support.constraint.ConstraintLayout
        android:id="@+id/constraintLayout14"
        style="@style/TextoBlanco3D"
        android:layout_width="0dp"
        android:layout_height="wrap_content"
        app:layout_constraintTop_toTopOf="parent"
        android:layout_marginTop="16dp"
        android:layout_marginLeft="16dp"
        app:layout_constraintLeft_toLeftOf="parent"
        android:layout_marginRight="16dp"
        app:layout_constraintRight_toRightOf="parent">

        <ImageView
            android:id="@+id/inicioImagenBombilla"
            style="@style/BotonTransparenteRojo"
            android:layout_width="35dp"
            android:layout_height="35dp"
            app:srcCompat="@mipmap/bulb"
            app:layout_constraintTop_toTopOf="parent"
            android:layout_marginTop="8dp"
            app:layout_constraintBottom_toBottomOf="parent"
            android:layout_marginBottom="8dp"
            android:layout_marginLeft="0dp"
            app:layout_constraintLeft_toLeftOf="parent" />

        <TextView
            android:id="@+id/inicioTextoDireccion"
            style="@style/LabelRojo"
            android:layout_width="0dp"
            android:layout_height="wrap_content"
            android:text="Direccion"
            app:layout_constraintRight_toLeftOf="@+id/inicioBotonAtras"
            android:layout_marginRight="4dp"
            app:layout_constraintBottom_toBottomOf="parent"
            android:layout_marginBottom="0dp"
            app:layout_constraintTop_toTopOf="parent"
            android:layout_marginTop="0dp"
            app:layout_constraintLeft_toRightOf="@+id/inicioImagenBombilla"
            android:layout_marginLeft="0dp" />

        <ImageButton
            android:id="@+id/inicioBotonAtras"
            style="@style/BotonTransparenteRojo"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            app:srcCompat="@mipmap/refresh"
            android:layout_marginRight="8dp"
            app:layout_constraintRight_toRightOf="parent"
            app:layout_constraintTop_toTopOf="parent"
            android:layout_marginTop="0dp"
            app:layout_constraintBottom_toBottomOf="parent"
            android:layout_marginBottom="0dp" />
    </android.support.constraint.ConstraintLayout>

    <android.support.constraint.ConstraintLayout
        android:id="@+id/constraintLayout16"
        style="@style/TextoBlanco3D"
        android:layout_width="0dp"
        android:layout_height="wrap_content"
        android:layout_marginLeft="16dp"
        android:layout_marginRight="4dp"
        android:layout_marginTop="8dp"
        app:layout_constraintHorizontal_bias="0.0"
        app:layout_constraintLeft_toLeftOf="parent"
        app:layout_constraintRight_toLeftOf="@+id/inicioBotonContrato"
        app:layout_constraintTop_toBottomOf="@+id/constraintLayout14">

        <ImageView
            android:id="@+id/imageView29"
            android:layout_width="10dp"
            android:layout_height="9dp"
            android:layout_marginBottom="0dp"
            android:layout_marginLeft="4dp"
            android:layout_marginTop="0dp"
            app:layout_constraintBottom_toTopOf="@+id/inicioLabelReportada"
            app:layout_constraintLeft_toLeftOf="parent"
            app:layout_constraintTop_toTopOf="@+id/inicioLabelDetectada"
            app:srcCompat="@mipmap/icosinsuministro" />

        <TextView
            android:id="@+id/inicioLabelDetectada"
            style="@style/LabelNegro"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_marginLeft="4dp"
            android:layout_marginRight="4dp"
            android:layout_marginTop="4dp"
            android:text="Incidencia detectada en la red"
            android:textSize="12dp"
            app:layout_constraintLeft_toRightOf="@+id/imageView29"
            app:layout_constraintRight_toRightOf="parent"
            app:layout_constraintTop_toTopOf="parent"
            app:layout_constraintHorizontal_bias="0.0" />

        <ImageView
            android:id="@+id/imageView30"
            android:layout_width="10dp"
            android:layout_height="10dp"
            android:layout_marginBottom="0dp"
            android:layout_marginLeft="4dp"
            android:layout_marginTop="0dp"
            app:layout_constraintBottom_toTopOf="@+id/inicioLabelSinIncidencia"
            app:layout_constraintLeft_toLeftOf="parent"
            app:layout_constraintTop_toTopOf="@+id/inicioLabelReportada"
            app:layout_constraintVertical_bias="0.5"
            app:srcCompat="@mipmap/icoaviso" />

        <TextView
            android:id="@+id/inicioLabelReportada"
            style="@style/LabelNegro"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_marginEnd="4dp"
            android:layout_marginLeft="4dp"
            android:layout_marginRight="4dp"
            android:layout_marginStart="4dp"
            android:layout_marginTop="4dp"
            android:text="Incidencia reportada"
            android:textSize="12dp"
            app:layout_constraintHorizontal_bias="0.0"
            app:layout_constraintLeft_toRightOf="@+id/imageView30"
            app:layout_constraintRight_toRightOf="parent"
            app:layout_constraintTop_toBottomOf="@+id/inicioLabelDetectada" />

        <ImageView
            android:id="@+id/imageView31"
            android:layout_width="10dp"
            android:layout_height="10dp"
            android:layout_marginLeft="4dp"
            android:layout_marginStart="4dp"
            app:layout_constraintBottom_toBottomOf="@+id/inicioLabelSinIncidencia"
            app:layout_constraintLeft_toLeftOf="parent"
            app:layout_constraintTop_toTopOf="@+id/inicioLabelSinIncidencia"
            app:layout_constraintVertical_bias="0.0"
            app:srcCompat="@mipmap/icosinproblemas" />

        <TextView
            android:id="@+id/inicioLabelSinIncidencia"
            style="@style/LabelNegro"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_marginBottom="4dp"
            android:layout_marginEnd="4dp"
            android:layout_marginLeft="4dp"
            android:layout_marginRight="4dp"
            android:layout_marginStart="4dp"
            android:layout_marginTop="4dp"
            android:text="Sin incidencia detectada o reportada"
            android:textSize="12dp"
            app:layout_constraintBottom_toBottomOf="parent"
            app:layout_constraintHorizontal_bias="0.0"
            app:layout_constraintLeft_toRightOf="@+id/imageView31"
            app:layout_constraintRight_toRightOf="parent"
            app:layout_constraintTop_toBottomOf="@+id/inicioLabelReportada"
            app:layout_constraintVertical_bias="0.0" />
    </android.support.constraint.ConstraintLayout>

    <Button
        android:id="@+id/inicioBotonContrato"
        style="@style/TextoBlanco3D"
        android:textColor="@color/colorRojoViesgo"
        android:layout_width="wrap_content"
        android:layout_height="0dp"
        android:layout_marginRight="16dp"
        android:layout_marginTop="0dp"
        android:text="Ver contrato"
        android:drawableTop="@mipmap/edit"
        app:layout_constraintRight_toRightOf="parent"
        app:layout_constraintTop_toTopOf="@+id/constraintLayout16"
        app:layout_constraintBottom_toBottomOf="@+id/constraintLayout16"
        android:layout_marginBottom="0dp">

    </Button>

    <com.google.android.gms.maps.MapView
        android:id="@+id/inicioMapa"
        style="@style/TextoBlanco3D"
        android:layout_width="0dp"
        android:layout_height="0dp"
        android:layout_marginBottom="8dp"
        android:layout_marginLeft="16dp"
        android:layout_marginRight="16dp"
        android:layout_marginTop="8dp"
        android:layout_weight="1"
        app:layout_constraintBottom_toTopOf="@+id/inicioLabelConsumos"
        app:layout_constraintHorizontal_bias="0.0"
        app:layout_constraintLeft_toLeftOf="parent"
        app:layout_constraintRight_toRightOf="parent"
        app:layout_constraintTop_toBottomOf="@+id/constraintLayout16" />

    <TextView
        android:id="@+id/inicioLabelConsumos"
        style="@style/LabelTituloRojo"
        android:layout_width="0dp"
        android:layout_height="wrap_content"
        android:text="Últimos consumos"
        app:layout_constraintLeft_toLeftOf="parent"
        app:layout_constraintRight_toRightOf="parent"
        app:layout_constraintHorizontal_bias="0.0"
        android:layout_marginLeft="16dp"
        android:layout_marginRight="16dp"
        android:layout_marginBottom="8dp"
        app:layout_constraintBottom_toTopOf="@+id/inicioRecyclerConsumos" />

    <android.support.v7.widget.RecyclerView
        android:id="@+id/inicioRecyclerConsumos"
        android:layout_width="0dp"
        android:layout_height="wrap_content"
        android:layout_marginBottom="8dp"
        android:layout_marginLeft="0dp"
        android:layout_marginRight="0dp"
        app:layout_constraintBottom_toBottomOf="parent"
        app:layout_constraintHorizontal_bias="0.0"
        app:layout_constraintLeft_toLeftOf="parent"
        app:layout_constraintRight_toRightOf="parent" />

0 个答案:

没有答案