Scalified / fab

Floating Action Button Library for Android
Apache License 2.0
849 stars 164 forks source link

Won't load in fragment #10

Closed dmuharemagic closed 9 years ago

dmuharemagic commented 9 years ago

Inflated it

    View view = inflater.inflate(R.layout.fragment_pocetna, container, false);
    listview = (ListView) view.findViewById(R.id.pocetna_listview);
    ActionButton actionButton = (ActionButton) view.findViewById(R.id.action_button);
    actionButton.show();

Here's my layout fragment_pocetna:

<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="fill_parent" android:layout_height="fill_parent" android:background="#ECECEC">

<android.support.v4.widget.SwipeRefreshLayout
    android:id="@+id/pocetna_swipe"
    android:layout_width="match_parent"
    android:layout_height="wrap_content">

<ListView
    android:layout_width="0dp"
    android:layout_height="match_parent"
    android:layout_weight="1"
    android:divider="@null"
    android:dividerHeight="0dp"
    android:transcriptMode="normal"
    android:id="@+id/pocetna_listview"
   />

</android.support.v4.widget.SwipeRefreshLayout>

<com.software.shell.fab.ActionButton
    android:id="@+id/action_button"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:layout_alignParentBottom="true"
    android:layout_alignParentRight="true"
    android:layout_marginRight="@dimen/fab_margin"
    android:layout_marginBottom="@dimen/fab_margin"
    />

</LinearLayout>

But doesn't seem to show. There's no errors in logcat. Thanks

vbaidak commented 9 years ago

Hi larryfour,

This is because of the LinearLayout. It doesn't allow you to properly place ActionButton to overlay other layout components. If you use LinearLayout you should provide a "place" for it like create inside it another layout etc.

I suggest you to use RelativeLayout instead of LinerLayout. This will solve your issue completely.

BTW, you do not need to call show() method explicitly - ActionButton will be shown if it is declared in the layout. If you need to play animation during the first appearing, just call playShowAnimation()

This should help Have a nice day :)