android 之 高德地图-定位-poi-marker

来源:互联网 发布:nodejs数据库前端显示 编辑:程序博客网 时间:2024/04/29 08:54
import android.Manifest;import android.annotation.TargetApi;import android.content.Context;import android.content.DialogInterface;import android.content.pm.PackageManager;import android.graphics.BitmapFactory;import android.graphics.Color;import android.icu.text.SimpleDateFormat;import android.os.Build;import android.os.Bundle;import android.support.v4.app.ActivityCompat;import android.support.v4.content.ContextCompat;import android.support.v7.app.AlertDialog;/** * Created by wcj on 17/10/30. */public class InterestActivity extends BaseActivity implements View.OnClickListener,        PoiSearch.OnPoiSearchListener, AMap.OnMapClickListener, AMap.OnMarkerClickListener {    private static final String TAG = InterestActivity.class.getSimpleName();    private TitleBar titleBar;    private AMap aMap;    private MapView mapView;    private String shur_province = "";    private String shur_city = "";    private final static LatLng SYDNEY = new LatLng(-33.86759, 151.2088);    private final static LatLng BEIJING = new LatLng(39.8965, 116.4074);    protected String[] needPermissions = {            Manifest.permission.ACCESS_COARSE_LOCATION,            Manifest.permission.ACCESS_FINE_LOCATION,            Manifest.permission.WRITE_EXTERNAL_STORAGE,            Manifest.permission.READ_EXTERNAL_STORAGE,            Manifest.permission.READ_PHONE_STATE    };    private static final int PERMISSON_REQUESTCODE = 0;    /**     * 判断是否需要检测,防止不停的弹框     */    private boolean isNeedCheck = true;    private Marker locationMarker; // 选择的点    //地图定位蓝点    private MyLocationStyle myLocationStyle;    private ClearEditText seach_quarters;    private ListView seach_list;    private TextView city_text;    private int currentPage = 1;//地图POI返回页码    private int num = 20;//设置每页最多返回多少条poiitem    private LatLonPoint lp= new LatLonPoint(39.8965, 116.4074);;//当前坐标    private String deepType = "商务住宅|住宿服务";    private List<PoiItem> poiItems;// poi数据    private myPoiOverlay poiOverlay;// poi图层    private TextView poi_detail_text;    private ImageButton refresh_icon;//刷新    private ImageButton go_btn;//滚动初始位置    private TextView other_btn;//其他    private TextView ok_btn;//确定    private RelativeLayout seach_bar;//搜索框    private RelativeLayout poi_detail_layout;    //声明AMapLocationClient类对象    public AMapLocationClient mLocationClient = null;    //声明AMapLocationClientOption对象    public AMapLocationClientOption mLocationOption = null;    //声明定位回调监听器    public AMapLocationListener mLocationListener = new AMapLocationListener() {        @TargetApi(Build.VERSION_CODES.N)        @Override        public void onLocationChanged(AMapLocation aMapLocation) {            if (aMapLocation != null) {                if (aMapLocation.getErrorCode() == 0) {                    //可在其中解析amapLocation获取相应内容。                    aMapLocation.getLocationType();//获取当前定位结果来源,如网络定位结果,详见定位类型表                    aMapLocation.getLatitude();//获取纬度                    aMapLocation.getLongitude();//获取经度                    aMapLocation.getAccuracy();//获取精度信息                    aMapLocation.getAddress();//地址,如果option中设置isNeedAddress为false,则没有此结果,网络定位结果中会有地址信息,GPS定位不返回地址信息。                    aMapLocation.getCountry();//国家信息                    String province = aMapLocation.getProvince();//省信息                    String city = aMapLocation.getCity();//城市信息                    aMapLocation.getDistrict();//城区信息                    aMapLocation.getStreet();//街道信息                    aMapLocation.getStreetNum();//街道门牌号信息                    aMapLocation.getCityCode();//城市编码                    aMapLocation.getAdCode();//地区编码                    aMapLocation.getAoiName();//获取当前定位点的AOI信息                    aMapLocation.getBuildingId();//获取当前室内定位的建筑物Id                    aMapLocation.getFloor();//获取当前室内定位的楼层                    aMapLocation.getGpsAccuracyStatus();//获取GPS的当前状态                    //获取定位时间                    SimpleDateFormat df = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");                    Date date = new Date(aMapLocation.getTime());                    df.format(date);                    shur_province = province;                    shur_city = city;                    city_text.setText(city);                    lp = new LatLonPoint(aMapLocation.getLatitude(),aMapLocation.getLongitude());//设置当前坐标经纬度                    locationMarker = aMap.addMarker(new MarkerOptions()                            .anchor(0.5f, 0.5f)                            .icon(BitmapDescriptorFactory                                    .fromBitmap(BitmapFactory.decodeResource(getResources(), R.mipmap.point4)))                            .position(new LatLng(lp.getLatitude(), lp.getLongitude())));                    aMap.moveCamera(CameraUpdateFactory.newLatLngZoom(new LatLng(aMapLocation.getLatitude(), aMapLocation.getLongitude()), 18));                    // 设置当前地图显示为当前位置//                    aMap.moveCamera(CameraUpdateFactory.newLatLngZoom(new LatLng(lp.getLatitude(), lp.getLongitude()), 14));//                    MarkerOptions markerOptions = new MarkerOptions();//                    markerOptions.position(new LatLng(lp.getLatitude(), lp.getLongitude()));//                    markerOptions.title("当前位置");//                    markerOptions.visible(true);//                    BitmapDescriptor bitmapDescriptor = BitmapDescriptorFactory.fromBitmap(BitmapFactory.decodeResource(getResources(), R.mipmap.point_icon));//                    markerOptions.icon(bitmapDescriptor);//                    aMap.addMarker(markerOptions);                    getBoundQuarters(city);                    Log.e(TAG, "当前定位点的AOI信息:" + aMapLocation.getLongitude()+"--"+ aMapLocation.getLatitude());                } else {                    //定位失败时,可通过ErrCode(错误码)信息来确定失败的原因,errInfo是错误信息,详见错误码表。                    Log.e("AmapError", "location Error, ErrCode:"                            + aMapLocation.getErrorCode() + ", errInfo:"                            + aMapLocation.getErrorInfo());                }            }        }    };    @Override    public void onCreate(Bundle savedInstanceState) {        super.onCreate(savedInstanceState);        setContentView(R.layout.activity_interest);        titleBar = (TitleBar) findViewById(R.id.title_bar);        titleBar.setTitleView(context.getResources().getString(R.string.interest));        titleBar.setTitleViewColor(context.getResources().getColor(R.color.white));        seach_quarters = (ClearEditText) findViewById(R.id.query);        seach_list = (ListView) findViewById(R.id.seach_list);        city_text = (TextView) findViewById(R.id.city_text);        poi_detail_text = (TextView)findViewById(R.id.poi_detail_text);        go_btn = (ImageButton)findViewById(R.id.go_btn);        refresh_icon = (ImageButton)findViewById(R.id.refresh_icon);        ok_btn = (TextView)findViewById(R.id.ok_btn);        other_btn=(TextView)findViewById(R.id.other_btn);        seach_bar = (RelativeLayout)findViewById(R.id.seach_bar);        poi_detail_layout = (RelativeLayout)findViewById(R.id.poi_detail_layout);        Shur_tool.setColor(this);        titleBar.setLeftImageClickListener(this);        go_btn.setOnClickListener(this);        refresh_icon.setOnClickListener(this);        ok_btn.setOnClickListener(this);        other_btn.setOnClickListener(this);        //获取地图控件引用        mapView = (MapView) findViewById(R.id.map);        mapView.onCreate(savedInstanceState);// 此方法必须重写        init();        MapsInitializer.loadWorldGridMap(true);        myLocationStyle = new MyLocationStyle();//初始化定位蓝点样式类        myLocationStyle.interval(2000);//设置连续定位模式下的定位间隔,只在连续定位模式下生效,单次定位模式下不会生效。单位为毫秒。        myLocationStyle.showMyLocation(false);//设置是否显示定位小蓝点,用于满足只想使用定位,不想使用定位小蓝点的场景,设置false以后图面上不再有定位蓝点的概念,但是会持续回调位置信息。        myLocationStyle.myLocationType(MyLocationStyle.LOCATION_TYPE_FOLLOW);        aMap.setMyLocationStyle(myLocationStyle);//设置定位蓝点的Style        aMap.getUiSettings().setMyLocationButtonEnabled(false);//设置默认定位按钮是否显示,非必需设置。        aMap.setMyLocationEnabled(true);// 设置为true表示启动显示定位蓝点,false表示隐藏定位蓝点并不进行定位,默认是false。//        aMap.addMarker(new MarkerOptions().position(FANGHENG)//                .title("方恒").snippet("方恒国际中心大楼A座"));        aMap.setMyLocationEnabled(true);// 设置为true表示显示定位层并可触发定位,false表示隐藏定位层并不可触发定位,默认是false        //aMap.getUiSettings().setMyLocationButtonEnabled(false);// 设置默认定位按钮是否显示        aMap.getUiSettings().setZoomControlsEnabled(false);        //初始化定位        mLocationClient = new AMapLocationClient(getApplicationContext());        //设置定位回调监听        mLocationClient.setLocationListener(mLocationListener);        //初始化AMapLocationClientOption对象        mLocationOption = new AMapLocationClientOption();        //设置定位模式为AMapLocationMode.Hight_Accuracy,高精度模式。        mLocationOption.setLocationMode(AMapLocationClientOption.AMapLocationMode.Hight_Accuracy);        //设置是否允许模拟位置,默认为true,允许模拟位置        mLocationOption.setOnceLocationLatest(true);        //单位是毫秒,默认30000毫秒,建议超时时间不要低于8000毫秒。        mLocationOption.setHttpTimeOut(80000);        //给定位客户端对象设置定位参数        mLocationClient.setLocationOption(mLocationOption);        //启动定位        mLocationClient.startLocation();        //搜索change事件        seach_quarters.addTextChangedListener(new TextWatcher() {            @Override            public void beforeTextChanged(CharSequence s, int start, int count, int after) {                Log.e(TAG, "seach text:" + s);            }            @Override            public void onTextChanged(CharSequence s, int start, int before, int count) {                Log.e(TAG, "seach text:" + s);                if (s.length() > 0) {                    getQuarters(s.toString(), shur_city);                }                if (s.length() == 0) {                    seach_list.setVisibility(View.GONE);                }            }            @Override            public void afterTextChanged(Editable s) {                Log.e(TAG, "seach text:" + s);            }        });        seach_quarters.setOnEditorActionListener(new TextView.OnEditorActionListener() {            @Override            public boolean onEditorAction(TextView v, int actionId, KeyEvent event) {                String s = v.getText().toString();                Log.e(TAG,"键盘回车:"+s);                if (s.length() > 0) {                    getQuarters(s, shur_city);                }                if (s.length() == 0) {                    seach_list.setVisibility(View.GONE);                }                return false;            }        });    }    /**     * 初始化AMap对象     */    private void init() {        if (aMap == null) {            aMap = mapView.getMap();            setUpMap();        }    }    /**     * 对地图添加onMapIsAbroadListener     */    private void setUpMap() {        aMap.setOnMapClickListener(this);        aMap.setOnMarkerClickListener(this);    }    /**     * 方法必须重写     */    @Override    protected void onResume() {        super.onResume();        mapView.onResume();        if (isNeedCheck) {            checkPermissions(needPermissions);        }    }    /**     * 方法必须重写     */    @Override    protected void onPause() {        super.onPause();        mapView.onPause();    }    /**     * 方法必须重写     */    @Override    protected void onSaveInstanceState(Bundle outState) {        super.onSaveInstanceState(outState);        mapView.onSaveInstanceState(outState);    }    /**     * 方法必须重写     */    @Override    protected void onDestroy() {        super.onDestroy();        mapView.onDestroy();    }    /**     * 刷新地图     */    public void refrashMap() {        aMap.invalidate();// 刷新地图    }    @Override    public void onClick(View v) {        switch (v.getId()) {            case R.id.left_img:                onBackPressed();                break;            case R.id.go_btn:                aMap.clear();                aMap.addMarker(new MarkerOptions()                        .anchor(0.5f, 0.5f)                        .icon(BitmapDescriptorFactory                                .fromBitmap(BitmapFactory.decodeResource(getResources(), R.mipmap.point4)))                        .position(new LatLng(lp.getLatitude(), lp.getLongitude())));                aMap.moveCamera(CameraUpdateFactory.newLatLngZoom(new LatLng(lp.getLatitude(), lp.getLongitude()), 18));                getBoundQuarters(shur_city);                break;            case R.id.refresh_icon:                //Toast.makeText(this, "刷新", Toast.LENGTH_SHORT).show();                refrashMap();// 刷新地图                break;            case R.id.ok_btn:                Toast.makeText(this, "确定", Toast.LENGTH_SHORT).show();                break;            case R.id.other_btn:                //Toast.makeText(this, "其他", Toast.LENGTH_SHORT).show();                seach_bar.setVisibility(View.VISIBLE);                poi_detail_layout.setVisibility(View.GONE);                seach_quarters.requestFocus();                //seach_quarters.setText("");                InputMethodManager imm = (InputMethodManager) getSystemService(Context.INPUT_METHOD_SERVICE);                imm.toggleSoftInput(0, InputMethodManager.HIDE_NOT_ALWAYS);                break;            default:                break;        }    }    /**     * 检查权限     *     * @param     * @since 2.5.0     */    private void checkPermissions(String... permissions) {        //获取权限列表        List<String> needRequestPermissonList = findDeniedPermissions(permissions);        if (null != needRequestPermissonList                && needRequestPermissonList.size() > 0) {            //list.toarray将集合转化为数组            ActivityCompat.requestPermissions(this,                    needRequestPermissonList.toArray(new String[needRequestPermissonList.size()]),                    PERMISSON_REQUESTCODE);        }    }    private List<String> findDeniedPermissions(String[] permissions) {        List<String> needRequestPermissonList = new ArrayList<String>();        //for (循环变量类型 循环变量名称 : 要被遍历的对象)        for (String perm : permissions) {            if (ContextCompat.checkSelfPermission(this,                    perm) != PackageManager.PERMISSION_GRANTED                    || ActivityCompat.shouldShowRequestPermissionRationale(                    this, perm)) {                needRequestPermissonList.add(perm);            }        }        return needRequestPermissonList;    }    /**     * 检测是否说有的权限都已经授权     *     * @param grantResults     * @return     * @since 2.5.0     */    private boolean verifyPermissions(int[] grantResults) {        for (int result : grantResults) {            if (result != PackageManager.PERMISSION_GRANTED) {                return false;            }        }        return true;    }    @Override    public void onRequestPermissionsResult(int requestCode, String[] permissions, int[] paramArrayOfInt) {        if (requestCode == PERMISSON_REQUESTCODE) {            if (!verifyPermissions(paramArrayOfInt)) {      //没有授权                finish();                isNeedCheck = false;            }        }    }    /**     * 显示提示信息     *     * @since 2.5.0     */    private void showMissingPermissionDialog() {        AlertDialog.Builder builder = new AlertDialog.Builder(this);        builder.setTitle("设置");        builder.setMessage("设置");        // 拒绝, 退出应用        builder.setNegativeButton(R.string.cancel,                new DialogInterface.OnClickListener() {                    @Override                    public void onClick(DialogInterface dialog, int which) {                        finish();                    }                });        builder.setPositiveButton(R.string.setting,                new DialogInterface.OnClickListener() {                    @Override                    public void onClick(DialogInterface dialog, int which) {                        //startAppSettings();                    }                });        builder.setCancelable(false);        builder.show();    }    @Override    public void onPoiSearched(PoiResult poiResult, int i) {        Log.e(TAG, "poi seached:" + poiResult.getPois());//        if (poiResult != null && poiResult.getQuery() !=null &&poiResult.getPois()=="") {//            Toast.makeText(this, getString(R.string.z_q_g_j_z), Toast.LENGTH_SHORT).show();//        }        List<Quarters> mData = new LinkedList<Quarters>();        final List<PoiItem> poi_list = poiResult.getPois();        for (int q = 0; q < poi_list.size(); q++) {            String qu = poi_list.get(q).toString();            mData.add(new Quarters(qu));        }        QuartersAdapter qadapter = new QuartersAdapter((LinkedList<Quarters>) mData, context);        seach_list.setAdapter(qadapter);        seach_list.setVisibility(View.VISIBLE);        seach_list.setOnItemClickListener(new AdapterView.OnItemClickListener() {            @Override            public void onItemClick(AdapterView<?> parent, View view, int position, long id) {                seach_bar.setVisibility(View.GONE);                seach_list.setVisibility(View.GONE);                poi_detail_layout.setVisibility(View.VISIBLE);                aMap.clear();                double latitude = poi_list.get(position).getLatLonPoint().getLatitude();                double longitude = poi_list.get(position).getLatLonPoint().getLongitude();                aMap.addMarker(new MarkerOptions()                        .anchor(0.5f, 0.5f)                        .icon(BitmapDescriptorFactory                                .fromBitmap(BitmapFactory.decodeResource(getResources(), R.mipmap.point4)))                        .position(new LatLng(latitude, longitude)));                aMap.moveCamera(CameraUpdateFactory.newLatLngZoom(new LatLng(latitude , longitude), 18));                poi_detail_text.setText(poi_list.get(position).toString());                String p=poi_list.get(position).getProvinceName();//省                String c=poi_list.get(position).getCityName();//市                //String e=poi_list.get(position).getSubPois();//区                Log.e(TAG,"sheng:"+p+",shi:"+c+",qu:"+poi_list.get(position).getIndoorData().getFloorName());                seach_quarters.clearFocus();                InputMethodManager imm = (InputMethodManager) getSystemService(Context.INPUT_METHOD_SERVICE);                imm.hideSoftInputFromWindow(view.getWindowToken(), 0);            }        });    }    @Override    public void onPoiItemSearched(PoiItem poiItem, int i) {    }    private void getQuarters(String s, String c) {//关键字POI检索        PoiSearch.Query quer_poi = new PoiSearch.Query(s, deepType, c);        quer_poi.setPageSize(num);// 设置每页最多返回多少条poiitem        quer_poi.setPageNum(currentPage);//设置查询页码        PoiSearch poiSearch = new PoiSearch(this, quer_poi);//构造 PoiSearch 对象        poiSearch.setOnPoiSearchListener(this);        poiSearch.searchPOIAsyn();//调用 PoiSearch 的 searchPOIAsyn() 方法发送请求。    }    private void getBoundQuarters(String c) {//周边5000米POI检索        PoiSearch.Query quer_poi = new PoiSearch.Query("", deepType, c);        quer_poi.setPageSize(num);// 设置每页最多返回多少条poiitem        quer_poi.setPageNum(0);//设置查询页码        if (lp != null) {            PoiSearch poiSearch = new PoiSearch(this, quer_poi);//构造 PoiSearch 对象            poiSearch.setOnPoiSearchListener(poiSeachListener);            poiSearch.setBound(new PoiSearch.SearchBound(lp, 1000, true));//            poiSearch.searchPOIAsyn();// 异步搜索        }    }    private PoiSearch.OnPoiSearchListener poiSeachListener = new PoiSearch.OnPoiSearchListener() {        @Override        public void onPoiSearched(PoiResult poiResult, int i) {            if (i == AMapException.CODE_AMAP_SUCCESS) {                if (poiResult != null && poiResult.getQuery() != null) {                    poiItems = poiResult.getPois();                    if (poiItems != null && poiItems.size() > 0) {                        poi_detail_text.setText(poiItems.get(0).toString());                        //清除POI信息显示                        //whetherToShowDetailInfo(false);                        //清理之前搜索结果的marker                        if (poiOverlay !=null) {                            poiOverlay.removeFromMap();                        }                        aMap.clear();                        poiOverlay = new myPoiOverlay(aMap, poiItems);                        poiOverlay.addToMap();                        poiOverlay.zoomToSpan();                        aMap.addMarker(new MarkerOptions()                                .anchor(0.5f, 0.5f)                                .icon(BitmapDescriptorFactory                                        .fromBitmap(BitmapFactory.decodeResource(                                                getResources(), R.mipmap.point4)))                                .position(new LatLng(lp.getLatitude(), lp.getLongitude())));                        aMap.addCircle(new CircleOptions()                                .center(new LatLng(lp.getLatitude(),                                        lp.getLongitude())).radius(1000)                                .strokeColor(Color.BLUE)                                .fillColor(Color.argb(50, 1, 1, 1))                                .strokeWidth(2));                    }                }            }        }        @Override        public void onPoiItemSearched(PoiItem poiItem, int i) {        }    };    @Override    public void onMapClick(LatLng latLng) {    }    @Override    public boolean onMarkerClick(Marker marker) {        Log.e(TAG,"make_click:"+marker.getZIndex());        poi_detail_text.setText(marker.getObject().toString());        return false;    }    private class myPoiOverlay {        private AMap mamap;        private List<PoiItem> mPois;        private ArrayList<Marker> mPoiMarks = new ArrayList<Marker>();        public myPoiOverlay(AMap amap ,List<PoiItem> pois) {            mamap = amap;            mPois = pois;        }        /**         * 添加Marker到地图中。         * @since V2.1.0         */        public void addToMap() {            for (int i = 0; i < mPois.size(); i++) {                Marker marker = mamap.addMarker(getMarkerOptions(i));                PoiItem item = mPois.get(i);                marker.setObject(item);                mPoiMarks.add(marker);            }        }        /**         * 去掉PoiOverlay上所有的Marker。         *         * @since V2.1.0         */        public void removeFromMap() {            for (Marker mark : mPoiMarks) {                mark.remove();            }        }        /**         * 移动镜头到当前的视角。         * @since V2.1.0         */        public void zoomToSpan() {            if (mPois != null && mPois.size() > 0) {                if (mamap == null)                    return;                LatLngBounds bounds = getLatLngBounds();                mamap.moveCamera(CameraUpdateFactory.newLatLngBounds(bounds, 100));            }        }        private LatLngBounds getLatLngBounds() {            LatLngBounds.Builder b = LatLngBounds.builder();            for (int i = 0; i < mPois.size(); i++) {                b.include(new LatLng(mPois.get(i).getLatLonPoint().getLatitude(),                        mPois.get(i).getLatLonPoint().getLongitude()));            }            return b.build();        }        private MarkerOptions getMarkerOptions(int index) {            return new MarkerOptions()                    .position(                            new LatLng(mPois.get(index).getLatLonPoint()                                    .getLatitude(), mPois.get(index)                                    .getLatLonPoint().getLongitude()))                    .title(getTitle(index)).snippet(getSnippet(index))                    .icon(getBitmapDescriptor(index));        }        protected String getTitle(int index) {            return mPois.get(index).getTitle();        }        protected String getSnippet(int index) {            return mPois.get(index).getSnippet();        }        /**         * 从marker中得到poi在list的位置。         *         * @param marker 一个标记的对象。         * @return 返回该marker对应的poi在list的位置。         * @since V2.1.0         */        public int getPoiIndex(Marker marker) {            for (int i = 0; i < mPoiMarks.size(); i++) {                if (mPoiMarks.get(i).equals(marker)) {                    return i;                }            }            return -1;        }        /**         * 返回第index的poi的信息。         * @param index 第几个poi。         * @return poi的信息。poi对象详见搜索服务模块的基础核心包(com.amap.api.services.core)中的类 <strong><a href="../../../../../../Search/com/amap/api/services/core/PoiItem.html" title="com.amap.api.services.core中的类">PoiItem</a></strong>。         * @since V2.1.0         */        public PoiItem getPoiItem(int index) {            if (index < 0 || index >= mPois.size()) {                return null;            }            return mPois.get(index);        }        protected BitmapDescriptor getBitmapDescriptor(int arg0) {            if (arg0 < 10) {                BitmapDescriptor icon = BitmapDescriptorFactory.fromBitmap(                        BitmapFactory.decodeResource(getResources(), R.mipmap.point_icon));                return icon;            }else {                BitmapDescriptor icon = BitmapDescriptorFactory.fromBitmap(                        BitmapFactory.decodeResource(getResources(), R.mipmap.point_icon));                return icon;            }        }    }}

布局文件

<?xml version="1.0" encoding="utf-8"?><RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"    android:layout_width="match_parent"    android:layout_height="match_parent"    android:background="@color/colorAccent"    android:orientation="vertical">    <cn.shur.task.widget.TitleBar        android:id="@+id/title_bar"        android:layout_width="match_parent"        android:layout_height="wrap_content"        android:visibility="gone" />    <com.amap.api.maps2d.MapView        android:id="@+id/map"        android:layout_width="match_parent"        android:layout_height="match_parent">    </com.amap.api.maps2d.MapView>    <RelativeLayout        android:id="@+id/seach_bar"        android:layout_width="match_parent"        android:layout_height="wrap_content"        android:layout_alignParentTop="true"        android:background="#30ffffff"        android:visibility="gone">        <cn.shur.task.ui.ClearEditText            android:id="@+id/query"            android:layout_width="match_parent"            android:layout_height="wrap_content"            android:layout_centerVertical="true"            android:background="@drawable/fillet_bg"            android:drawableLeft="@mipmap/em_search_bar_icon_normal"            android:drawablePadding="@dimen/shur_5"            android:focusable="true"            android:focusableInTouchMode="true"            android:hint="@string/xiaoqu"            android:imeOptions="actionSearch"            android:paddingBottom="15dp"            android:paddingLeft="15dp"            android:paddingTop="15dp"            android:singleLine="true"            android:textColorHint="#8C8C8C"            android:textSize="16sp" />        <TextView            android:id="@+id/city_text"            android:layout_width="40dp"            android:layout_height="wrap_content"            android:layout_alignParentRight="true"            android:layout_centerVertical="true"            android:layout_marginRight="10dp"            android:background="@android:color/transparent"            android:padding="6dp"            android:visibility="gone" />    </RelativeLayout>    <ListView        android:id="@+id/seach_list"        android:layout_width="wrap_content"        android:layout_height="wrap_content"        android:layout_below="@id/seach_bar"        android:background="#ffffff"        android:divider="@color/colorAccent"        android:scrollbars="none" />    <RelativeLayout        android:id="@+id/poi_detail_layout"        android:layout_width="match_parent"        android:layout_height="wrap_content"        android:layout_alignParentBottom="true"        >        <LinearLayout            android:id="@+id/btn"            android:layout_width="match_parent"            android:layout_height="wrap_content"            android:layout_alignParentTop="true"            android:gravity="right"            android:orientation="horizontal"            android:paddingRight="@dimen/shur_17">            <ImageButton                android:id="@+id/refresh_icon"                android:layout_width="wrap_content"                android:layout_height="wrap_content"                android:layout_margin="@dimen/shur_5"                android:background="@null"                android:src="@drawable/refresh_icon"                />            <ImageButton                android:id="@+id/go_btn"                android:layout_width="wrap_content"                android:layout_height="wrap_content"                android:layout_margin="@dimen/shur_5"                android:background="@null"                android:gravity="end"                android:src="@drawable/go_icon" />        </LinearLayout>        <LinearLayout            android:layout_width="match_parent"            android:layout_height="wrap_content"            android:orientation="vertical"            android:layout_below="@id/btn"            android:padding="@dimen/shur_17"            android:background="@color/white">            <TextView                android:id="@+id/poi_detail_text"                android:layout_width="match_parent"                android:layout_height="wrap_content" />            <TextView                android:layout_width="match_parent"                android:layout_height="wrap_content"                android:text="@string/q_r_x_q"                android:textSize="@dimen/shur_10"/>            <LinearLayout                android:layout_width="match_parent"                android:layout_height="wrap_content"                android:orientation="horizontal"                android:layout_marginTop="@dimen/shur_25"                android:gravity="right">                <TextView                    android:id="@+id/other_btn"                    android:layout_width="wrap_content"                    android:layout_height="wrap_content"                    android:text="@string/x_z_q_t_x_q"                    android:padding="@dimen/shur_5"/>                <TextView                    android:id="@+id/ok_btn"                    android:layout_width="wrap_content"                    android:layout_height="wrap_content"                    android:padding="@dimen/shur_5"                    android:layout_marginLeft="@dimen/shur_17"                    android:text="@string/ok"/>            </LinearLayout>        </LinearLayout>    </RelativeLayout></RelativeLayout>

相关配置:android 6.0 \ gradle-3.3 \  地图版本:2DMap_V5.2.0 \ 手机型号:m8_华为