Is there any way to add a button to the bottom of preferences screen and make them work correct when scrolling?
相关问题
- How can I create this custom Bottom Navigation on
- Bottom Navigation View gets Shrink Down
- How to make that the snackbar action button be sho
- Listening to outgoing sms not working android
- How to create Circular view on android wear?
相关文章
- android开发 怎么把图片放入drawable的文件夹下
- android上如何获取/storage/emulated/下的文件列表
- androidStudio有个箭头不认识
- SQLite不能创建表
- Windows - Android SDK manager not listing any plat
- Animate Recycler View grid when number of columns
- Why is the app closing suddenly without showing an
- Android OverlayItem.setMarker(): Change the marker
Custom view in Preference Activity this will help to add custom view in PreferenceActivity in Android.
Create main.xml, the only necessary view is a ListView, with id:
android:id="@android:id/list"
.Create CustomPreferenceActivity.java
Actually, there is a solution. Here is a code, i hope, this will be useful for anyone. It looks like 3 options and 2 buttons in the bottom of the screen, independent of screen resolution (was targeted to 240 as lowest)
There is another solution for customizing the appearance of the preferences.
Design a normal XML layout with buttons or whatever you want to add to the standard preferences. Include a
ListView
in your layout and give it the ID@android:id/list
.Let's say we call the layout file
res/layout/main.xml
. It could look something like this:In your
PreferenceActivity
, add these two lines to youronCreate
:The
ListView
in your layout will then be replaced by the preferences defined the usual way inres/xml/preferences.xml
.I reference @Ronnie, use RelativeLayout and set a height for layout_height of listview, and then set the button's layout_alignParentBottom = "true", It can render a button at the bottom of PreferenceScreen; then use the way of @Max. it works for my needs.
preferences.xml:
SettingsFragment.java: