尝试使用
http://blog.yeyanxiang.cn/Android/notes/android/surfaceview-corner/ 解决地图圆形问题,但是失败
This commit is contained in:
5
.idea/misc.xml
generated
5
.idea/misc.xml
generated
@@ -4,10 +4,7 @@
|
||||
<asm skipDebug="false" skipFrames="false" skipCode="false" expandFrames="false" />
|
||||
<groovy codeStyle="LEGACY" />
|
||||
</component>
|
||||
<component name="ProjectRootManager" version="2" languageLevel="JDK_1_8" default="true" project-jdk-name="1.8" project-jdk-type="JavaSDK">
|
||||
<component name="ProjectRootManager" version="2" languageLevel="JDK_1_8" default="true" project-jdk-name="JDK" project-jdk-type="JavaSDK">
|
||||
<output url="file://$PROJECT_DIR$/build/classes" />
|
||||
</component>
|
||||
<component name="SuppressionsComponent">
|
||||
<option name="suppComments" value="[]" />
|
||||
</component>
|
||||
</project>
|
||||
@@ -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);
|
||||
}
|
||||
}
|
||||
Binary file not shown.
|
Before Width: | Height: | Size: 28 KiB After Width: | Height: | Size: 29 KiB |
@@ -3,7 +3,6 @@
|
||||
xmlns:app="http://schemas.android.com/apk/res-auto"
|
||||
android:layout_width="@dimen/module_small_map_border_view_width"
|
||||
android:layout_height="@dimen/module_small_map_border_view_width"
|
||||
android:background="#ffffff"
|
||||
app:roundLayoutRadius="360dp">
|
||||
|
||||
<com.mogo.module.common.view.RoundLayout
|
||||
@@ -11,7 +10,6 @@
|
||||
android:layout_width="@dimen/module_small_map_view_width"
|
||||
android:layout_height="@dimen/module_small_map_view_width"
|
||||
android:layout_centerInParent="true"
|
||||
android:background="#3F51B5"
|
||||
app:roundLayoutRadius="360dp">
|
||||
|
||||
<com.mogo.module.small.map.SmallMapView
|
||||
|
||||
Reference in New Issue
Block a user