java - float 操作按钮可见性问题?

标签 java android-layout floating-action-button

在下面的代码中,我试图使 fab 按钮在 sip 调用期间可见,并在调用结束时不可见。有些 fab7.show 不显示任何内容,只有 fab8.hide() 在 oncallend 函数内工作。任何帮助将不胜感激。

In the below code, when the Fab button was touched for more than 3 second(inside onTouchListener) , i am calling sendingcall function and at the same time make fab8 visible.

when the call is ended , by default below function oncallend function is called , in that function i am hiding fab8.

  fab.setOnTouchListener(new View.OnTouchListener() {
            @Override


            public boolean onTouch(View v, MotionEvent event) {
                call.setListener(myListener);

                switch(event.getAction()){
                    case MotionEvent.ACTION_DOWN:
                        down = System.currentTimeMillis();
                        break;
                    case MotionEvent.ACTION_UP:
                        //this is the time in milliseconds
                        re= System.currentTimeMillis();
                        differ = System.currentTimeMillis()- down;

                        if(differ>=3000){
                            sendingCall();

                            FloatingActionButton fab8 = (FloatingActionButton) findViewById(R.id.fab8);
                             fab8.show();

                        }
                        break;

                }

onCallEnded function is called everytime when the call is ended. And here i am hiding fab button

  public void onCallEnded(SipAudioCall endedCall) {


       FloatingActionButton fab8 = (FloatingActionButton) findViewById(R.id.fab8);
        fab8.hide();  //***only hide works **
     FloatingActionButton fab7 = (FloatingActionButton)  findViewById(R.id.fab7);
     fab7.show();       //.  ******does not shows********
                    Log.d("call", "Call ended.................................");


}

最佳答案

因此,从我看来,您在 onTouch 事件中使用 .setVisibility() ,在 onCallEnded 方法中使用 hide() 函数。 因此,不要使用 .hide ,而是尝试使用 setVisibility() 再次隐藏按钮。

关于java - float 操作按钮可见性问题?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/58641861/

相关文章:

java - 如何递归一个字符串以验证它只包含第一个字符后的数字

android - 线性布局中的自动调整项目

ios - 使用 Floaty 库显示矩形按钮

java - 为什么未填充此数组?

java - Spring 数据 JPA OutOfMemoryError : GC overhead limit exceeded

java - 有没有可能在 Java 7 (byte) ((char) ByteBuffer.get(X)) != ByteBuffer.get(X) 中?

显示像素化的 Android 抽屉导航项目图标

java - 将适配器应用于 Spinner 会导致 NullPointerException?

android - 两个相邻的 float 操作按钮

android - 隐藏/显示带有比例动画的工厂