Browse Source

修改地图逻辑

czq 2 years ago
parent
commit
f74abfc6cf

+ 8 - 7
app/src/main/java/com/xunao/effectdemo/activity/MapChallengeActivity.java

@@ -1,7 +1,6 @@
 package com.xunao.effectdemo.activity;
 
-import static com.blankj.utilcode.util.ScreenUtils.getScreenHeight;
-import static com.blankj.utilcode.util.ScreenUtils.getScreenWidth;
+import static com.blankj.utilcode.util.ScreenUtils.*;
 
 import android.app.Activity;
 import android.content.Intent;
@@ -58,8 +57,9 @@ public class MapChallengeActivity extends Activity {
     void initData(){
         getMap();
     }
-
+    private float scale = 0f;
     void initView(){
+        scale = (float) (getAppScreenHeight ()/1024.00);
         llMapBg = findViewById(R.id.ll_map_bg);
         rlMapBg = findViewById(R.id.rl_map_bg);
         btnMap1 = findViewById(R.id.btn_map_1);
@@ -122,10 +122,11 @@ public class MapChallengeActivity extends Activity {
                 .format(DecodeFormat.PREFER_RGB_565)
                 .into(child);
         child.setScaleType(ImageView.ScaleType.FIT_XY);
-        child.setLayoutParams(new ViewGroup.LayoutParams(ViewGroup.LayoutParams.WRAP_CONTENT,getScreenHeight()));
+        child.setLayoutParams(new ViewGroup.LayoutParams(getAppScreenHeight (),getAppScreenHeight ()));
         llMapBg.addView(child);
     }
 
+
     private void addSmallBg(String url, double x, double y){
         ImageView child = new ImageView(this);
 //        Glide.with(this).asBitmap().load(url).into(new BitmapImageViewTarget(child){
@@ -140,9 +141,9 @@ public class MapChallengeActivity extends Activity {
                 .format(DecodeFormat.PREFER_RGB_565)
                 .into(child);
         child.setScaleType(ImageView.ScaleType.FIT_XY);
-        RelativeLayout.LayoutParams layoutParams = new RelativeLayout.LayoutParams(360,300);
-        layoutParams.leftMargin = (int)(x * getScreenWidth()*11);
-        layoutParams.topMargin = (int)(y * getScreenHeight());
+        RelativeLayout.LayoutParams layoutParams = new RelativeLayout.LayoutParams((int) (scale*376), (int) (scale*306));
+        layoutParams.leftMargin = (int)(x * getAppScreenHeight ()*bkg_images.size());
+        layoutParams.topMargin = (int)(y * getAppScreenHeight ());
         child.setLayoutParams(layoutParams);
         rlMapBg.addView(child);
     }