拖把耶
拖把耶
  • 发布:2016-01-08 17:54
  • 更新:2016-01-08 18:01
  • 阅读:1442

原生ImageView 的问题

分类:5+ SDK

因为要做地图选择位置,我需要一个原生的ImageView 放到地图正中间

为此研究了插件开发,一路坑啊坑 终于明白明白怎么回事了,写了个ImageView。。。

点击插件有反应。。但是出来的ImageView 把整个APP 都占了。满屏了。。。。

请问代码要怎么改

package co.zhimai.ps;  
import android.app.Activity;  
import android.content.Context;  
import android.content.res.AssetManager;  
import android.graphics.Bitmap;  
import android.graphics.BitmapFactory;  
import android.util.Log;  
import android.widget.FrameLayout;  
import android.widget.ImageView;  

import org.json.JSONArray;  

import java.io.IOException;  
import java.io.InputStream;  

import io.dcloud.common.DHInterface.IWebview;  
import io.dcloud.common.DHInterface.StandardFeature;  
import io.dcloud.common.util.JSUtil;  
public class NativeUITB extends StandardFeature {  

    public void imageView(IWebview pWebview, JSONArray array){  
        String CallBackID = array.optString(0);  
        String image = array.optString(1); //图片地址  
        Integer width = array.optInt(2); //宽度  
        Integer height = array.optInt(3);//高度  
        Integer top = array.optInt(4);  
        Integer right = array.optInt(5);  
        Integer bottom = array.optInt(6);  
        Integer left = array.optInt(7);  
        Activity activity = pWebview.getActivity();  
        Context context = pWebview.getContext();  
        ImageView iv = new ImageView(activity);  
        FrameLayout.LayoutParams lp = new FrameLayout.LayoutParams(width, height);  
        lp.setMargins(left, top, right, bottom);  
        iv.setLayoutParams(lp);  
        AssetManager asset = activity.getAssets();  
        InputStream img = null;  
        String path = "";  
        try{  
            path = "apps/HelloH5/www/"+image;  
            img = asset.open(path);  
            Bitmap bmp= BitmapFactory.decodeStream(img);  
            iv.setImageBitmap(bmp);  
            activity.setContentView(iv);  
        }catch(IOException e){  
           Log.e("liuxinglei",e.getMessage());  
        }  
        JSUtil.execCallback(pWebview, CallBackID, "", JSUtil.OK, false);  

    }  

}  
2016-01-08 17:54 负责人:无 分享
已邀请:
拖把耶

拖把耶 (作者)

activity.setContentView(iv);  

这代码一填充 把整个APP都占满屏了,,

  • 拖把耶 (作者)

    addContentView

    2016-01-19 10:35

该问题目前已经被锁定, 无法添加新回复