尝试使用
http://blog.yeyanxiang.cn/Android/notes/android/surfaceview-corner/ 解决地图圆形问题,但是失败
This commit is contained in:
@@ -1,6 +1,7 @@
|
||||
package com.mogo.module.small.map;
|
||||
|
||||
import android.content.Context;
|
||||
import android.os.Build;
|
||||
import android.os.Bundle;
|
||||
import android.util.AttributeSet;
|
||||
import android.view.View;
|
||||
@@ -8,6 +9,7 @@ import android.view.ViewGroup;
|
||||
import android.widget.FrameLayout;
|
||||
|
||||
import androidx.annotation.Nullable;
|
||||
import androidx.annotation.RequiresApi;
|
||||
|
||||
import com.mogo.map.MogoBaseMapView;
|
||||
import com.mogo.utils.logger.Logger;
|
||||
@@ -32,6 +34,7 @@ public class SmallMapView extends MogoBaseMapView {
|
||||
super(context, attrs, defStyleAttr);
|
||||
}
|
||||
|
||||
@RequiresApi(api = Build.VERSION_CODES.LOLLIPOP)
|
||||
@Override
|
||||
protected void addMapView(Context context) {
|
||||
Logger.d(TAG, "addMapView");
|
||||
@@ -39,6 +42,8 @@ public class SmallMapView extends MogoBaseMapView {
|
||||
if (mMapView != null) {
|
||||
final View mapView = mMapView.getMapView();
|
||||
if (mapView != null) {
|
||||
mapView.setOutlineProvider(new TextureVideoViewOutlineProvider(360));
|
||||
mapView.setClipToOutline(true);
|
||||
addView(mapView, new FrameLayout.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.MATCH_PARENT));
|
||||
} else {
|
||||
Logger.e(TAG, "create MapView instance failed.");
|
||||
|
||||
@@ -73,7 +73,6 @@ public class SmallVisionProvider implements IMogoSmallMapProvider, IMogoStatusCh
|
||||
@Override
|
||||
public void showPanel() {
|
||||
Log.d(TAG, "小地图模块触发展示……");
|
||||
|
||||
if (MogoApisHandler.getInstance().getApis().getStatusManagerApi().isVrMode()) {
|
||||
mSmallMapServiceIntent = new Intent(mContext, SmallMapService.class);
|
||||
mContext.startService(mSmallMapServiceIntent);
|
||||
@@ -83,10 +82,8 @@ public class SmallVisionProvider implements IMogoSmallMapProvider, IMogoStatusCh
|
||||
@Override
|
||||
public void hidePanel() {
|
||||
Log.d(TAG, "小地图模块触发隐藏……");
|
||||
if (MogoApisHandler.getInstance().getApis().getStatusManagerApi().isVrMode()) {
|
||||
if (mSmallMapServiceIntent != null) {
|
||||
AbsMogoApplication.getApp().stopService(mSmallMapServiceIntent);
|
||||
}
|
||||
if (mSmallMapServiceIntent != null) {
|
||||
AbsMogoApplication.getApp().stopService(mSmallMapServiceIntent);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -0,0 +1,35 @@
|
||||
package com.mogo.module.small.map;
|
||||
|
||||
import android.graphics.Outline;
|
||||
import android.graphics.Rect;
|
||||
import android.os.Build;
|
||||
import android.util.Log;
|
||||
import android.view.View;
|
||||
import android.view.ViewOutlineProvider;
|
||||
|
||||
import androidx.annotation.RequiresApi;
|
||||
|
||||
/**
|
||||
* @author donghongyu
|
||||
* @date 12/15/20 8:47 PM
|
||||
*/
|
||||
@RequiresApi(api = Build.VERSION_CODES.LOLLIPOP)
|
||||
public class TextureVideoViewOutlineProvider extends ViewOutlineProvider {
|
||||
private float mRadius;
|
||||
|
||||
public TextureVideoViewOutlineProvider(float radius) {
|
||||
this.mRadius = radius;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void getOutline(View view, Outline outline) {
|
||||
Log.w("OutlineProvider", "======getOutline======");
|
||||
Rect rect = new Rect();
|
||||
view.getGlobalVisibleRect(rect);
|
||||
int leftMargin = 0;
|
||||
int topMargin = 0;
|
||||
Rect selfRect = new Rect(leftMargin, topMargin,
|
||||
rect.right - rect.left - leftMargin, rect.bottom - rect.top - topMargin);
|
||||
outline.setRoundRect(selfRect, mRadius);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user