小编Joe*_*ooy的帖子

删除CardView Overdraw

我在attemtp上运行了我的app上的"Debug GPU Overdraw"工具,以减少透支量.如下图所示,cardview就像一个额外的透支层.我没有给我的其他布局提供任何额外的背景颜色或图像.

有办法解决这个问题吗?

在此输入图像描述

<?xml version="1.0" encoding="utf-8"?>
<android.support.v7.widget.CardView xmlns:card_view="http://schemas.android.com/apk/res-auto"
    xmlns:android="http://schemas.android.com/apk/res/android"
    android:id="@+id/card_view"
    android:layout_width="match_parent"
    android:layout_height="350dp"
    card_view:cardCornerRadius="10dp"
    android:layout_margin="10dp">
    <RelativeLayout
        android:layout_width="match_parent"
        android:layout_height="match_parent">
        <RelativeLayout
            android:layout_width="match_parent"
            android:layout_height="match_parent">
            <LinearLayout
                android:id="@+id/container_top"
                android:layout_width="match_parent"
                android:layout_height="60dp"
                android:background="#fff"
                android:layout_alignParentTop="true"
                android:orientation="horizontal">
                <RelativeLayout
                    android:layout_width="0dp"
                    android:layout_height="match_parent"
                    android:layout_weight="1">
                    <ImageView
                        android:id="@+id/thumbnail_profile"
                        android:layout_width="50dp"
                        android:layout_height="50dp"
                        android:scaleType="centerCrop"
                        android:layout_centerInParent="true"/>
                </RelativeLayout>
                <RelativeLayout
                    android:layout_width="0dp"
                    android:layout_height="match_parent"
                    android:layout_weight="3">
                    <LinearLayout
                        android:layout_width="wrap_content"
                        android:layout_height="wrap_content"
                        android:orientation="vertical"
                        android:layout_centerVertical="true"
                        android:layout_marginLeft="5dp">
                        <TextView
                            android:id="@+id/created_by"
                            android:textSize="13sp"
                            android:textStyle="bold"
                            android:layout_width="wrap_content"
                            android:layout_height="wrap_content"/>
                        <TextView
                            android:id="@+id/time_ago"
                            android:textSize="10sp"
                            android:layout_width="wrap_content"
                            android:layout_height="wrap_content"/>
                    </LinearLayout>
                </RelativeLayout>
                <RelativeLayout
                    android:layout_width="0dp"
                    android:layout_height="match_parent"
                    android:layout_weight="1">
                    <LinearLayout
                        android:layout_width="wrap_content"
                        android:layout_height="wrap_content"
                        android:orientation="horizontal"
                        android:layout_centerVertical="true"
                        android:layout_marginLeft="5dp">
                        <ImageView
                            android:id="@+id/likes_logo"
                            android:layout_width="wrap_content"
                            android:layout_height="wrap_content"
                            android:src="@drawable/ic_like_red"/>
                        <TextView
                            android:id="@+id/likes_product"
                            android:layout_width="wrap_content" …
Run Code Online (Sandbox Code Playgroud)

performance android

13
推荐指数
1
解决办法
778
查看次数

Google会在Android上使用群集映射自定义标记图标

我已经实现了Google Maps Clustering的代码

这是我活动中的代码

private void setUpClusterer() {
    mClusterManager = new ClusterManager<StoreItem>(this, mMap);
    mMap.setOnCameraChangeListener(mClusterManager);
    mMap.setOnMarkerClickListener(mClusterManager);
}

public void addItems(List<Store> stores) {
    for (Store store : stores) {
        mClusterManager.addItem(new StoreItem(store.getImage(), store.getLocation().getLatitude(), store.getLocation().getLongitude()));
    }
}

private void removeAllItems() {
    mClusterManager.clearItems();
}
Run Code Online (Sandbox Code Playgroud)

这是StoreItem类

public class StoreItem implements ClusterItem {

    private String url;
    private final LatLng mPosition;

    public StoreItem(String url, double lat, double lng) {
        this.url = url;
        mPosition = new LatLng(lat, lng);
    }

    @Override
    public LatLng getPosition() {
        return mPosition;
    } …
Run Code Online (Sandbox Code Playgroud)

android google-maps google-maps-markers android-maps-utils

7
推荐指数
1
解决办法
5285
查看次数

在API级别19到22的android中检索当前位置

我在项目中使用下面的代码来检索用户的当前位置.但是,这似乎适用于我的API级别23的测试设备,但在我的API级别19到22的测试设备上不起作用.对位置的请求将返回null,因此将我放在坐标0,0 ..

如何获得API级别19到22的正确坐标?

package be.enventorslab.pingvalue;

import android.content.IntentSender;
import android.content.pm.PackageManager;
import android.location.Location;
import android.support.v7.app.AppCompatActivity;
import android.os.Bundle;
import android.util.Log;

import com.google.android.gms.common.ConnectionResult;
import com.google.android.gms.common.api.GoogleApiClient;
import com.google.android.gms.location.LocationListener;
import com.google.android.gms.location.LocationRequest;
import com.google.android.gms.location.LocationServices;
import com.google.android.gms.maps.CameraUpdateFactory;
import com.google.android.gms.maps.GoogleMap;
import com.google.android.gms.maps.SupportMapFragment;
import com.google.android.gms.maps.model.CameraPosition;
import com.google.android.gms.maps.model.LatLng;
import com.google.android.gms.maps.model.MarkerOptions;

import be.enventorslab.pingvalue.functions.Functions;

public class NearbyLocationActivity extends AppCompatActivity
        implements GoogleApiClient.ConnectionCallbacks,
        GoogleApiClient.OnConnectionFailedListener,
        LocationListener {

        public static final String TAG = NearbyLocationActivity.class.getSimpleName();

        private final static int CONNECTION_FAILURE_RESOLUTION_REQUEST = 9000;

        private GoogleMap mMap;

        private GoogleApiClient mGoogleApiClient;
        private LocationRequest mLocationRequest;

        Bundle bundle;

        @Override
        protected void onCreate(Bundle …
Run Code Online (Sandbox Code Playgroud)

android google-api-client android-maps-v2

5
推荐指数
0
解决办法
402
查看次数