在线时间:8:00-16:00
迪恩网络APP
随时随地掌握行业动态
扫描二维码
关注迪恩网络微信公众号
开源软件名称(OpenSource Name):michael-rapp/AndroidMaterialPreferences开源软件地址(OpenSource Url):https://github.com/michael-rapp/AndroidMaterialPreferences开源编程语言(OpenSource Language):Java 100.0%开源软件介绍(OpenSource Introduction):AndroidMaterialPreferences - README"AndroidMaterialPreferences" is an Android-library, which provides various preferences, which are designed according to Android 5's Material Design guidelines even on pre-Lollipop devices. The library provides the following preferences:
Prior to version 4.0.0 this library relied on the Android SDK's preference classes such as License AgreementThis project is distributed under the Apache License version 2.0. For further information about this license agreement's content please refer to its full version, which is available at http://www.apache.org/licenses/LICENSE-2.0.txt. Prior to version 2.0.4 this library was distributed under the GNU Lesser General Public License version 3.0 (GLPLv3). DownloadThe latest release of this library can be downloaded as a zip archive from the download section of the project's Github page, which is available here. Furthermore, the library's source code is available as a Git repository, which can be cloned using the URL https://github.com/michael-rapp/AndroidMaterialPreferences.git. Alternatively, the library can be added to your Android app as a Gradle dependency by adding the following to the respective module's dependencies {
compile 'com.github.michael-rapp:android-material-preferences:5.3.2'
} Before version 2.0.0 this project was hosted on Sourceforge. These older versions used the legacy Eclipse ADT folder structure and are not available as Gradle artifacts. ExamplesThe following examples provide a quick overview on how to use the preferences, which are provided by the library, in your own Android app. This project also contains the source code of an example app, which implements use cases of the library for demonstration purposes, as well as a more detailed documentation in the Wiki and auto-generated javadoc files. Since version 5.0.0 the library requires to use AndroidX instead of the older AppCompat support libraries. Make sure that you have migrated your app to AndroidX and that you are using one of the Material component themes instead of the AppCompat ones, e.g. Specifying a themeMost of the preferences, which are provided by the library show a dialog when the respective preference is clicked. The theme, which should be used for the dialogs, can be specified by using the theme attribute <resources>
<style name="AppTheme" parent="@style/Theme.MaterialComponents.Light.DarkActionBar">
<item name="colorPrimary">@color/color_primary</item>
<item name="colorPrimaryDark">@color/color_primary_dark</item>
<item name="colorAccent">@color/color_accent</item>
<item name="preferenceDialogTheme">@style/CustomLightTheme</item>
</style>
<style name="CustomLightTheme" parent="@style/MaterialDialog.Light">
<item name="colorAccent">@color/color_accent</item>
</style>
</resources> If the theme of one of the preferences used in the app should differ from those used by the other ones, the attribute Showing a headerAll preferences, which show a dialog, when they are clicked, can show a header at the top of their dialog. The header may contain a background color or image as well as an icon. In order to show such a header, the following XML attributes have to be added to the XML resource, which is used to declare the preference: custom:showDialogHeader="true"
custom:dialogHeaderBackground="@drawable/dialog_header_background"
custom:dialogHeaderIcon="@drawable/dialog_header_icon" A preference's dialog, which contains such a header, may look like shown in the screenshot below: SeekBarPreferenceThe XML code below shows how to declare a <?xml version="1.0" encoding="utf-8"?>
<PreferenceScreen xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:custom="http://schemas.android.com/apk/res-auto" >
<de.mrapp.android.preference.SeekBarPreference
android:defaultValue="33.336"
android:dialogTitleColor="@android:color/black"
android:dialogMessageColor="@android:color/black"
android:dialogButtonTextColor="@android:color/black"
android:dialogBackground="@android:color/white"
android:dialogMessage="@string/seek_bar_preference_dialog_message"
android:dialogTitle="@string/seek_bar_preference_dialog_title"
android:key="@string/seek_bar_preference_key"
android:max="150"
android:summary="@array/seek_bar_preference_summaries"
android:title="@string/seek_bar_preference_title"
custom:decimals="2"
custom:floatingPointSeparator="."
custom:min="25"
custom:showProgress="true"
custom:showValueAsSummary="false"
custom:unit="Unit"
custom:dialogThemeResource="@style/MaterialDialog" />
</PreferenceScreen> The following screenshot shows how a EditTextPreferenceThe example below shows how the attributes of an <?xml version="1.0" encoding="utf-8"?>
<PreferenceScreen xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:custom="http://schemas.android.com/apk/res-auto" >
<de.mrapp.android.preference.EditTextPreference
android:defaultValue="DefaultText"
android:dialogTitleColor="@android:color/black"
android:dialogMessageColor="@android:color/black"
android:dialogButtonTextColor="@android:color/black"
android:dialogBackground="@android:color/white"
android:dialogMessage="@string/edit_text_preference_dialog_message"
android:dialogTitle="@string/edit_text_preference_dialog_title"
android:key="@string/edit_text_preference_key"
android:summary="@string/edit_text_preference_summary"
android:title="@string/edit_text_preference_title"
custom:showValueAsSummary="false"
custom:dialogThemeResource="@style/MaterialDialog" />
</PreferenceScreen> The picture shown below show the appearance of a ListPreferenceThe example illustrates how the attributes of a <?xml version="1.0" encoding="utf-8"?>
<PreferenceScreen xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:custom="http://schemas.android.com/apk/res-auto" >
<de.mrapp.android.preference.ListPreference
android:defaultValue=0
android:entries="R.array.list_preference_entries"
android:entryValues="R.array.list_preference_entry_values"
android:dialogTitleColor="@android:color/black"
android:dialogMessageColor="@android:color/black"
android:dialogButtonTextColor="@android:color/black"
android:dialogBackground="@android:color/white"
android:dialogItemColor="@android:color/black"
android:dialogItemControlColor="@android:color/black"
android:dialogMessage="@string/list_preference_dialog_message"
android:dialogTitle="@string/list_preference_dialog_title"
android:key="@string/list_preference_key"
android:summary="@array/list_preference_summary"
android:title="@string/list_preference_title"
custom:showValueAsSummary="false"
custom:dialogThemeResource="@style/MaterialDialog" />
</PreferenceScreen> The screenshot below illustrates the appearance of a MultiChoiceListPreferenceThe following XML code shows how the attributes of a <?xml version="1.0" encoding="utf-8"?>
<PreferenceScreen xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:custom="http://schemas.android.com/apk/res-auto" >
<de.mrapp.android.preference.MultiChoiceListPreference
android:defaultValue="R.array.multi_choice_list_preference_entry_values"
android:entries="R.array.multi_choice_list_preference_entries"
android:entryValues="R.array.multi_choice_list_preference_entry_values"
android:dialogTitleColor="@android:color/black"
android:dialogMessageColor="@android:color/black"
android:dialogButtonTextColor="@android:color/black"
android:dialogBackground="@android:color/white"
android:dialogItemColor="@android:color/black"
android:dialogItemControlColor="@android:color/black"
android:dialogMessage="@string/multi_choice_list_preference_dialog_message"
android:dialogTitle="@string/multi_choice_list_preference_dialog_title"
android:key="@string/multi_choice_list_preference_key"
android:summary="@array/multi_choice_list_preference_summary"
android:title="@string/multi_choice_list_preference_title"
custom:showValueAsSummary="false"
custom:dialogThemeResource="@style/MaterialDialog" />
</PreferenceScreen> The screenshot, which is shown in the following, illustrates how a NumberPickerPreferenceThe following example illustrates how of a <?xml version="1.0" encoding="utf-8"?>
<PreferenceScreen xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:custom="http://schemas.android.com/apk/res-auto" >
<de.mrapp.android.preference.NumberPickerPreference
android:defaultValue="25"
custom:min="0"
android:max="100"
custom:useInputMethod="true"
custom:wrapSelectorWheel="false"
android:dialogTitleColor="@android:color/black"
android:dialogMessageColor="@android:color/black"
android:dialogButtonTextColor="@android:color/black"
android:dialogBackground="@android:color/white"
android:dialogMessage="@string/number_picker_preference_dialog_message"
android:dialogTitle="@string/number_picker_preference_dialog_title"
android:key="@string/number_picker_preference_key"
android:summary="@array/number_picker_preference_summary"
android:title="@string/number_picker_preference_title"
custom:unit="Unit"
custom:stepSize="5"
custom:showValueAsSummary="false"
custom:dialogThemeResource="@style/MaterialDialog" />
</PreferenceScreen> The screenshot below illustes how a DigitPickerPreferenceThe following example illustrates how of a <?xml version="1.0" encoding="utf-8"?>
<PreferenceScreen xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:custom="http://schemas.android.com/apk/res-auto" >
<de.mrapp.android.preference.DigitPickerPreference
android:defaultValue="25"
custom:numberOfDigits="2"
custom:useInputMethod="true"
custom:wrapSelectorWheel="false"
android:dialogTitleColor="@android:color/black"
android:dialogMessageColor="@android:color/black"
android:dialogButtonTextColor="@android:color/black"
android:dialogBackground="@android:color/white"
android:dialogMessage="@string/digit_picker_preference_dialog_message"
android:dialogTitle="@string/digit_picker_preference_dialog_title"
android:key="@string/digit_picker_preference_key"
android:summary="@array/digit_picker_preference_summary"
android:title="@string/digit_picker_preference_title"
custom:unit="Unit"
custom:showValueAsSummary="false"
custom:dialogThemeResource="@style/MaterialDialog" />
</PreferenceScreen> The image shown below shows the appearance of a ResolutionPreferenceThe following XML code shows how of a <?xml version="1.0" encoding="utf-8"?>
<PreferenceScreen xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:custom="http://schemas.android.com/apk/res-auto" >
<de.mrapp.android.preference.ResolutionPreference
android:defaultValue="1024x768"
custom:unit=@string/resolution_preference_unit
android:dialogTitleColor="@android:color/black"
android:dialogMessageColor="@android:color/black"
android:dialogButtonTextColor="@android:color/black"
android:dialogBackground="@android:color/white"
android:dialogMessage="@string/resolution_preference_dialog_message"
android:dialogTitle="@string/resolution_preference_dialog_title"
android:key="@string/resolution_preference_key"
android:summary="@array/resolution_preference_summary"
android:title="@string/resolution_preference_title"
custom
|
2023-10-27
2022-08-15
2022-08-17
2022-09-23
2022-08-13
请发表评论