小编Nic*_*k.K的帖子

如何为谷歌地图设置自定义标记标题

如何设置包含信息和按钮的样式自定义标记标题/片段?我已经有一个自定义标记图标图像集。现在我需要一个自定义弹出窗口,当用户点击标记时,该窗口将包含某些信息和一个按钮。

这与我想要实现的目标很接近。

自定义标题/片段示例

自定义标题/片段示例

 LatLng huduma_gpo = new LatLng(-1.280694, 36.818277);
            googleMap.addMarker(new MarkerOptions().position(huduma_gpo).title("Huduma center GPO")).setIcon(BitmapDescriptorFactory.fromBitmap(marker));

            // For zooming automatically to the location of the marker
            googleMap.moveCamera( CameraUpdateFactory.newLatLngZoom(huduma_gpo , 12.0f) );
Run Code Online (Sandbox Code Playgroud)

android google-maps

5
推荐指数
1
解决办法
6411
查看次数

Onclick 不适用于 CardView

我在 cardview 上有一个 onclick 侦听器。侦听器仅在我点击内容(TextViews/ImageViews)之外的区域时才起作用。我的卡片视图中也有一个线性布局。我希望当我点击 CardView 上的任何地方时它都能工作。与我的做法相比,有没有更好的方法来实现这一点?

这是我在 xml 中的 CardView

<android.support.v7.widget.CardView
    xmlns:card_view="http://schemas.android.com/apk/res-auto"
    android:id="@+id/card_view"
    android:layout_gravity="center"
    android:padding="10dp"
    android:layout_margin="3dp"
    android:elevation="3dp"
    android:layout_width="match_parent"
    android:layout_height="match_parent">

    <LinearLayout
        android:layout_width="match_parent"
        android:orientation="vertical"
        android:layout_height="wrap_content">
        <TextView
            android:id="@+id/post_type"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:background="@drawable/guilt_theme"
            android:padding="4dp"
            android:text="GUILT"
            android:textColor="@color/textColor"
            android:textSize="12sp"
            android:textStyle="bold" />

        <TextView
            android:id="@+id/post_text"
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:textAllCaps="false"
            android:layout_marginTop="10dp"
            android:focusableInTouchMode="false"
            android:clickable="true"
            android:text="text content"
            android:textColor="@color/secondaryText"
            android:textSize="16sp" />

        <TextView
            android:id="@+id/date_user"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_marginTop="3dp"
            android:inputType="number"
            android:text="on 16/5/2018 by user"
            android:textColor="@color/weaker_text"
            android:textSize="14sp" />

        <LinearLayout
            android:id="@+id/LinearLayout"
            android:layout_width="match_parent"
            android:orientation="horizontal"
            android:layout_height="wrap_content">

            <ImageView
                android:id="@+id/view_image"
                android:layout_width="20dp"
                android:layout_height="20dp"
                android:clickable="true"
                android:focusable="true"
                android:background="?attr/selectableItemBackground"
                android:layout_marginTop="4dp"
                android:src="@drawable/ic_action_name" />

            <TextView
                android:id="@+id/total_views"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content" …
Run Code Online (Sandbox Code Playgroud)

android cardview

5
推荐指数
1
解决办法
4303
查看次数

标签 统计

android ×2

cardview ×1

google-maps ×1