亚洲城娱乐关于Unity调用android jar 求大神看下代码

( 亚洲城娱乐 )

需求用unity去调用android的jar jar里面是个浮动框的代码 浮动框的图片打包在assets里面

public class TTest extends UnityPlayerActivity {
    
    InterFace inter;
    Put p = new Put();
    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);

    }
    public void Input(){    
           p.Dosome(null, inter);
    }
}

一下是浮动框代码

public Put extend Activity{
public void Dosome(Activity activity,Inter inter){
        Log.i("TEST","------>")        
display = Put.this.getWindowManager().getDefaultDisplay();
        mWM = (WindowManager) Put.this.getSystemService(Put.this.WINDOW_SERVICE);
        ivCursor = new ImageView(Put.this);
        try {
            Drawable drawable = Drawable.createFromStream(Put.this.getAssets().open("tom.jpg"), "tom");
            ivCursor.setImageDrawable(drawable);
            //ivCursor.setBackground(new BitmapDrawable(BitmapFactory.decodeStream(activity.getAssets().open("Tom.jpg"))));
        } catch (IOException e) {
            // TODO Auto-generated catch block
            e.printStackTrace();
        }
        //ivCursor.setImageResource(MResource.getIdByName(activity.getApplication(),"drawable","tom"));
        mParams = new WindowManager.LayoutParams();// 对ivCursor东西的参数描绘东西
        mParams.height = WindowManager.LayoutParams.WRAP_CONTENT;
        mParams.width = WindowManager.LayoutParams.WRAP_CONTENT;
        mParams.flags = WindowManager.LayoutParams.FLAG_NOT_FOCUSABLE;// 设置成不克不及获取核心
        mParams.type = LayoutParams.TYPE_PHONE;
        // 设置图片款式,结果为背景透明
        mParams.format = PixelFormat.RGBA_8888;
        mParams.gravity = Gravity.TOP | Gravity.LEFT;
        mParams.x = 0;// 相干于屏幕原点的x轴间隔
        mParams.y = 0;// 相干于屏幕原点的y轴间隔
        System.out.println("<-----");
        mWM.addView(ivCursor, mParams);
    }

}

就如许值打出第一个log 就完事了 那个浮动框也没表现 这是怎样回事啊 求大神帮忙表明下啊

(看完/读完)这篇文章有何感想! 亚洲城娱乐的分享…

发表评论

电子邮件地址不会被公开。 必填项已用*标注