我的頁面中有一個scrollview,它包含一個線性佈局。我的要求是在滾動此佈局時添加一個浮動按鈕,並在此按鈕上單擊執行操作。如何才能做到這一點。請幫助我。提前致謝。如何在android中滾動時添加浮動按鈕?
2
A
回答
4
也許我誤解了你的問題,但它聽起來像你想要一個固定的Button
以外的ScrollView
,以便您可以滾動並始終看到Button
?
如果是這樣,只需添加Button
OUTSIDE的ScrollView
:你需要
<Button
android:id="@+id/button_save"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:text="Save" />
<ScrollView
android:id="@+id/scrollView_list"
android:layout_width="fill_parent"
android:layout_height="fill_parent" >
<LinearLayout
android:id="@+id/linearLayout2"
android:layout_width="fill_parent"
android:layout_height="fill_parent" >
</LinearLayout>
</ScrollView>
3
使用this library,它已經做過的事情。
包括在您的項目:
dependencies {
compile 'com.shamanland:fab:0.0.5'
}
添加FloatingActionButton
到您的佈局,而不是常規Button
:
<com.shamanland.fab.FloatingActionButton
android:id="@+id/button_save"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
/>
鏈接它ScrollView
:
FloatingActionButton fab = (FloatingActionButton) findViewById(R.id.button_save);
ScrollView scrollView = (ListView) findViewById(R.id.scrollView_list);
scrollView.setOnTouchListener(new ShowHideOnScroll(fab));
這一切,它應該工作!
查看我的original post here並查看example app。
相關問題
- 1. 如何在UITableViewController中添加浮動按鈕,該按鈕在滾動表格時不滾動?
- 2. 如何在volusion站點中添加滾動到頂部的浮動按鈕?
- 3. 浮動動作按鈕滾動內容
- 4. 如何在PDF中添加浮動按鈕?
- 5. Android按鈕自動滾動
- 6. Android按鈕浮動佈局
- 7. 當列表不能滾動時隱藏浮動動作按鈕
- 8. 如何在tableView控制器上添加浮動按鈕
- 9. 如何添加浮動在UIScrollView之上的按鈕?
- 10. 如何在浮動操作按鈕下添加AdMob
- 11. 滾動視圖上的Android浮動按鈕
- 12. 的Android:重新按下按鈕時動態添加按鈕
- 13. 如何隱藏嵌套滾動上的浮動操作按鈕
- 14. 如何在Android中的Alert Box中動態添加按鈕
- 15. 浮動按鈕
- 16. Android如何在我的自定義ListView上添加一些浮動按鈕?
- 17. 如何在右下角顯示浮動動作按鈕 - android
- 18. 如何在列表視圖上添加滾動按鈕?
- 19. 如何在滾動視圖上添加多個按鈕
- 20. 使用Webview滾動時隱藏浮動按鈕隱藏
- 21. android水平滾動按鈕
- 22. 如何在每個Android活動中添加圖像按鈕?
- 23. 如何在Android中單擊浮動按鈕時通過AccessibilityService執行滾動事件?
- 24. 想要在列表視圖中添加兩個浮動按鈕
- 25. 如何在android上的webview上顯示浮動按鈕android
- 26. 如何在android中動態添加滾動視圖
- 27. 在活動中添加動態輸入文本和按鈕android
- 28. 如何在android中添加按鈕?
- 29. 如何在android中添加按鈕?
- 30. 如何在滾動時隱藏按鈕並在滾動停止時顯示?
在按鈕和滾動視圖之外,可以使用一個relativelayout進行換行。並且Button可以與android:layout_alignParentBottom =「true」,android:layout_alignParentRight =「true」一起使用以對齊到父母的右下位置。 – juejiang 2015-09-29 02:28:30