我的頁面中有一個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. 如何在iOS相機中添加浮動按鈕?
- 5. 如何在PDF中添加浮動按鈕?
- 6. 滾動按鈕android
- 7. Android按鈕自動滾動
- 8. 如何在android中更改浮動動作按鈕?
- 9. Android按鈕浮動佈局
- 10. 當列表不能滾動時隱藏浮動動作按鈕
- 11. 如何在滾動文本的同時在textview下隱藏浮動按鈕
- 12. 如何在UITableView上添加浮動按鈕?
- 13. 如何添加浮動在UIScrollView之上的按鈕?
- 14. 如何在tableView控制器上添加浮動按鈕
- 15. 如何在浮動操作按鈕下添加AdMob
- 16. 動態創建和添加滾動按鈕的按鈕
- 17. 如何添加動畫效果左右滾動按鈕單擊?
- 18. 滾動視圖上的Android浮動按鈕
- 19. 的Android:重新按下按鈕時動態添加按鈕
- 20. [Android]如何在點擊按鈕時動態添加圖像按鈕?
- 21. 如何隱藏嵌套滾動上的浮動操作按鈕
- 22. 浮動動作按鈕附加錨不隱藏時滾動RecyclerView項慢
- 23. 如何在Android中的Alert Box中動態添加按鈕
- 24. 如何在android中的ListView中動態添加textview和按鈕?
- 25. 浮動按鈕
- 26. Android如何在我的自定義ListView上添加一些浮動按鈕?
- 27. 如何在右下角顯示浮動動作按鈕 - android
- 28. 關閉浮動動作按鈕Android
- 29. 如何在android中按下按鈕時添加動態佈局的一部分?
- 30. 如何在列表視圖上添加滾動按鈕?
在按鈕和滾動視圖之外,可以使用一個relativelayout進行換行。並且Button可以與android:layout_alignParentBottom =「true」,android:layout_alignParentRight =「true」一起使用以對齊到父母的右下位置。 – juejiang 2015-09-29 02:28:30