//Parent View
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="@drawable/back4">
//Relative Layout Child of ScrollView
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_marginTop="40dp">
//Grid View with Parent Relative Layout. Grid View not allowing floating button to align bottom
<GridView
android:id="@+id/gridview"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:verticalSpacing="50dp">
</GridView>
//Floating Button adding to Bottom of screen
<com.google.android.material.floatingactionbutton.FloatingActionButton
android:id="@+id/addNew"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="@+id/gridview"
android:layout_alignParentEnd="true"
android:src="@drawable/addbutton"/>
//End of Relative Layout
</RelativeLayout>
//End of Scroll View
Make some changes to your FloatingActionButton XML. Hope this works for you!
<com.google.android.material.floatingactionbutton.FloatingActionButton
android:id="@+id/addNew"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentEnd="true"
android:layout_alignParentRight="true"
android:layout_alignParentBottom="true"
android:layout_margin="16dp"
android:src="@drawable/addbutton" />
Also, there is no need of vertically scrolling ScrollView as GridView is also a vertically scrolling widget(GridView).
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.