Android overlay a view ontop of everything?

前端 未结 6 2174
旧巷少年郎
旧巷少年郎 2020-11-29 01:11

Can you overlay a view on top of everything in android?

In iPhone I would get the new view set its frame.origin to (0,0) and its width and height to the

6条回答
  •  谎友^
    谎友^ (楼主)
    2020-11-29 01:24

    I have tried the awnsers before but this did not work. Now I jsut used a LinearLayout instead of a TextureView, now it is working without any problem. Hope it helps some others who have the same problem. :)

        view = (LinearLayout) findViewById(R.id.view); //this is initialized in the constructor
        openWindowOnButtonClick();
    
    public void openWindowOnButtonClick()
    {
        view.setAlpha((float)0.5);
        FloatingActionButton fb = (FloatingActionButton) findViewById(R.id.floatingActionButton);
        final InputMethodManager keyboard = (InputMethodManager) getSystemService(getBaseContext().INPUT_METHOD_SERVICE);
        fb.setOnClickListener(new View.OnClickListener()
        {
            @Override
            public void onClick(View v)
            {
                // check if the Overlay should be visible. If this value is false, it is not shown -> show it.
                if(view.getVisibility() == View.INVISIBLE)
                {
                    view.setVisibility(View.VISIBLE);
                    keyboard.toggleSoftInput(InputMethodManager.SHOW_IMPLICIT, 0);
                    Log.d("Overlay", "Klick");
                }
                else if(view.getVisibility() == View.VISIBLE)
                {
                    view.setVisibility(View.INVISIBLE);
                    keyboard.toggleSoftInput(0, InputMethodManager.HIDE_IMPLICIT_ONLY);
                }
    

提交回复
热议问题