0

I am unable to hide fab button in arc menu programmatically. I am using https://github.com/saurabharora90/MaterialArcMenu in my code . how to hide fab used inside arc menu, programmatically in Java I have already tried: but it's not working

upload.hide();  

Custom auto hide floatingActionButton behavior is not working and FloatingActionButton doesn't hide

<com.sa90.materialarcmenu.ArcMenu
    android:id="@+id/arcMenu"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:layout_gravity="bottom|end"
    android:layout_alignParentBottom="true"
    android:layout_alignParentLeft="true"
    android:layout_marginBottom="-10dp"
    android:layout_marginLeft="-10dp"
    app:fabSize="normal"
    app:menu_scr="@android:drawable/ic_dialog_dialer"
    app:menu_open="arc_right">

    <com.melnykov.fab.FloatingActionButton
        android:id="@+id/upload"
        android:layout_width="wrap_content"
        android:src="@android:drawable/ic_menu_upload"
        android:layout_height="wrap_content" />

</com.sa90.materialarcmenu.ArcMenu>
Cœur
  • 37,241
  • 25
  • 195
  • 267

3 Answers3

0

You need to set the visibility of the view to GONE. In your code, you need to get a reference to the view you want to hide either using findViewById or if you use Data Binding in your project.

If your code is in Java, use

view.setVisibility(View.GONE)

or in Kotlin, use

view.visibility = View.GONE
Mayokun
  • 1,084
  • 1
  • 8
  • 20
0

You Have to Manage the visibility of the view programatically.

    if (App.getInstance().getAllowVideoComments() == ACCOUNT_STATE_ENABLED) { 
         if (upload.getVisibility() == View.VISIBLE) {
               upload.setVisibility(View.GONE);               
         }else{
           upload.setVisibility(View.VISIBLE); 
         }
    } else { 
      //Creating the Toast object 
     if (upload.getVisibility() == View.VISIBLE) {
          upload.setVisibility(View.GONE);}
 Toast.makeText(Createrelation.this, " Elite Editor",Toast.LENGTH_SHORT).show(); }
Mayur Rajvir
  • 140
  • 5
  • if (App.getInstance().getAllowVideoComments() == ACCOUNT_STATE_ENABLED) { upload.setVisibility(View.VISIBLE); } else { //Creating the Toast object upload.setVisibility(View.GONE); Toast.makeText(Create.this, " Elite Editor", Toast.LENGTH_SHORT).show(); } still not working – rabinarayan bhukta Jan 15 '20 at 13:22
  • @rabinarayanbhukta please try updated answer.And please dont hide/show upload button in xml. – Mayur Rajvir Jan 15 '20 at 13:30
0

In Kotlin you can remove from layout the fab button like this:

upload.visibility = View.GONE 

it will "remove" your fab button from the layout 
(will not take place some space in your layout and will not clickable) 

or you can use:

upload.visibility = View.INVISIBLE

It will just hide your fab button but will still take place space on your 
layout and will still clickable.

Also, you can use a boolean value:

upload.isVisible = true/false 
it analogical:
upload.visibility = View.VISIBLE - true / upload.visibility = View.GONE - false.
Max Shwed
  • 232
  • 2
  • 10
  • tried upload.setVisibility(View.GONE);, still not working. i think is there any relation with arc menu so=ince for other fabbutton whic are not part of arc menu there setVisibility(View.GONE);is working – rabinarayan bhukta Jan 15 '20 at 13:49
  • Please, try this: upload.isVisible = false – Max Shwed Jan 15 '20 at 13:54
  • in java it is saying isVisible() cannot applied to FAB to booleean – rabinarayan bhukta Jan 16 '20 at 05:51
  • I see u use a fab button from the outside library. I think u сan use it instead your fab button to solve your problem:         ...         ...         ...       - it is a fab button from official google library and then use above solutions to hide button. – Max Shwed Jan 16 '20 at 12:18
  • i have one file where i am using – rabinarayan bhukta Jan 16 '20 at 13:10
  • Override public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {..... if App.getInstance().getAllowVideoComments() == ACCOUNT_STATE_DISABLED) { mFabButton.setVisibility(View.GONE); } it is working but in file where i am having problem is ..here i am using Override protected void onCreate(Bundle savedInstanceState) { if (App.getInstance().getAllowVideoComments() == ACCOUNT_STATE_ENABLED) { ...}else {upload.setVisibility(View.GONE); is there any problem here – rabinarayan bhukta Jan 16 '20 at 13:16
  • both are same library – rabinarayan bhukta Jan 16 '20 at 13:17