简体   繁体   中英

Error in Android 2.x with the infowindow background

This is my problem in all info window I have are too big, and I like to set up at 180dp height and 300dp width, or warp_content instead:

在此处输入图片说明

I realized that the problem only occurs in version 2.2 and Android 2.3, on Android 4.1 dont have problems, and I do not try on version 3.x

Any idea how to fix it?

I read other post that said changed the getInfoContent for getInfoWindow , but I already have that way.

InfoWindow.xml:

<?xml version="1.0" encoding="utf-8"?>
 <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
 android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:background="#243439"
android:orientation="horizontal" >

<ImageView 
android:id="@+id/imagen"
android:layout_width="114dp"
android:layout_weight="0.5"
android:layout_height="174dp"
android:contentDescription="@string/app_name"/>

<LinearLayout
android:layout_width="174dp"
android:layout_height="174dp"
android:orientation="vertical" >

<TextView
android:id="@+id/titulo"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_marginTop="5dp"
android:textColor="#FFFFFF" 
android:gravity="center_horizontal|center"
android:textSize="17sp"
android:textStyle="bold" />

<TextView
android:id="@+id/direccion"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_marginTop="14dp"
android:textColor="#FFFFFF" 
android:gravity="center_horizontal|center"
android:textSize="12sp" />

<TextView
android:id="@+id/vermas"
android:layout_width="fill_parent"
android:layout_height="match_parent"
android:textColor="#FFFFFF" 
android:gravity="bottom|center_horizontal"
android:text="@string/vermas"
android:textSize="12sp" />

</LinearLayout>
</LinearLayout>

The fragment.java:

googlemap.setInfoWindowAdapter(new InfoWindowAdapter() {

@Override
public View getInfoWindow(Marker marker) {

View v = getLayoutInflater(null).inflate(R.layout.infowindow, null);

TextView titulo = (TextView) v.findViewById(R.id.titulo);
TextView direccion = (TextView) v.findViewById(R.id.direccion);
ImageView imagen = ((ImageView)v.findViewById(R.id.imagen));

titulo.setText(marker.getTitle());
direccion.setText(marker.getSnippet());

if(hash.get(marker) != null)
imagen.setImageDrawable(getResources().getDrawable(hash.get(marker)));

return v;

}
//..
@Override
public View getInfoContents(Marker marker) {
// TODO Auto-generated method stub
return null;
}
});
}

try below coxmk

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:background="#243439"
    android:orientation="horizontal" >

    <ImageView
        android:id="@+id/imagen"
        android:layout_width="0dp"
        android:layout_height="100dp"
        android:layout_weight="0.5"
        android:contentDescription="@string/app_name" />

    <LinearLayout
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:orientation="vertical" >

        <TextView
            android:id="@+id/titulo"
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:layout_marginTop="5dp"
            android:gravity="center_horizontal|center"
            android:textColor="#FFFFFF"
            android:textSize="17sp"
            android:textStyle="bold" />

        <TextView
            android:id="@+id/direccion"
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:layout_marginTop="14dp"
            android:gravity="center_horizontal|center"
            android:textColor="#FFFFFF"
            android:textSize="12sp" />

        <TextView
            android:id="@+id/vermas"
            android:layout_width="match_parent"
            android:layout_height="match_parent"
            android:gravity="bottom|center_horizontal"
            android:text="test"
            android:textColor="#FFFFFF"
            android:textSize="12sp" />
    </LinearLayout>

</LinearLayout>

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM