Reputation:
I have a ListView which gets it's data from an adapter which puts 2 TextViews inside. I also Have a Button, to add things to the list But when when my Listview has to much items, it covers the Button:
And I just can't get rid of it!
Here is the Layout of the activity in the Picture:
activity_default_color.xml
<?xml version="1.0" encoding="utf-8"?>
<FrameLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="horizontal"
android:padding="10dp" >
<FrameLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content">
<RelativeLayout
android:layout_height="fill_parent"
android:layout_width="fill_parent">
<com.software.shell.fab.ActionButton
xmlns:fab="http://schemas.android.com/apk/res-auto"
android:id="@+id/action_button"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
fab:type="DEFAULT"
fab:button_color="@color/fab_material_orange_500"
fab:button_colorPressed="@color/fab_material_lime_900"
fab:image="@drawable/fab_plus_icon"
fab:image_size="24dp"
fab:shadow_color="#757575"
fab:shadow_radius="5.0dp"
fab:shadow_xOffset="1dp"
fab:shadow_yOffset="1dp"
fab:show_animation="@anim/fab_roll_from_down"
fab:hide_animation="@anim/fab_roll_to_down"
android:layout_gravity="right|bottom"
android:layout_alignParentBottom="true"
android:layout_alignParentRight="true"
android:layout_alignParentEnd="true"/>
</RelativeLayout>
</FrameLayout>
<FrameLayout
android:layout_width="fill_parent"
android:layout_height="fill_parent">
<RelativeLayout
android:layout_height="fill_parent"
android:layout_width="fill_parent">
<ListView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:id="@+id/colorList"
android:layout_weight="1" />
</RelativeLayout>
</FrameLayout>
</FrameLayout>
Here is my Adapter Layout: myAdapter_item.xml
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="vertical"
android:layout_width="wrap_content"
android:layout_height="wrap_content">
<TextView
android:id="@android:id/text1"
android:layout_width="1000dp" <!-- I now it's ugly but match_parent doesn't work -->
android:layout_height="30dp"
android:textSize="20dp"
android:layout_marginTop="1dp"/>
<TextView
android:id="@android:id/text2"
android:layout_width="1000dp" <!-- I now it's ugly but match_parent doesn't work -->
android:layout_height="20dp"
android:layout_marginTop="0dp"/>
</LinearLayout>
How can i get the Button in absolut front
Upvotes: 0
Views: 3090
Reputation: 1215
I had the same problem but resolved by using below code..
Layout with listview and floating action button
<?xml version="1.0" encoding="utf-8"?>
<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:fab="http://schemas.android.com/apk/res-auto"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="#FFFFFF">
<ListView
android:id="@+id/provider_service_list"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:divider="#999999"
>
</ListView>
<com.melnykov.fab.FloatingActionButton
android:id="@+id/fab"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="bottom|right"
android:layout_margin="16dp"
android:src="@drawable/ic_action_add_icon"
fab:fab_colorNormal="#FF0000"
fab:fab_colorPressed="#DF0101"
fab:fab_colorRipple="@color/accent"
fab:fab_shadow="true"
fab:fab_type="normal"
/>
</FrameLayout>
Now whatever you are using in adapter no issue with that.
Thanks to https://github.com/makovkastar/FloatingActionButton
and in your class use this
ListView provider_service_list = (ListView)findViewById(R.id.provider_service_list);
FloatingActionButton fab = (FloatingActionButton)findViewById(R.id.fab);
fab.setShadow(true);
fab.attachToListView(provider_service_list);
Let me know if your problem does not solved with this.
Upvotes: 2