我在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) 我已经实现了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) 我在项目中使用下面的代码来检索用户的当前位置.但是,这似乎适用于我的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)