![](/img/trans.png)
[英]My button is not working, how can i make it work on android studio?
[英]how can i align my floating button to the bottom of the page in android studio
//父視圖
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="@drawable/back4">
//ScrollView的相對布局Child
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_marginTop="40dp">
//帶有父級相對布局的網格視圖。 網格視圖不允許浮動按鈕對齊底部
<GridView
android:id="@+id/gridview"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:verticalSpacing="50dp">
</GridView>
//浮動按鈕添加到屏幕底部
<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"/>
//相對布局結束
</RelativeLayout>
//滾動視圖結束
對您的 FloatingActionButton XML 進行一些更改。 希望這對你有用!
<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" />
此外,不需要垂直滾動 ScrollView,因為 GridView 也是一個垂直滾動小部件(GridView)。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.