在线时间:8:00-16:00
迪恩网络APP
随时随地掌握行业动态
扫描二维码
关注迪恩网络微信公众号
开源软件名称(OpenSource Name):daniel-stoneuk/material-about-library开源软件地址(OpenSource Url):https://github.com/daniel-stoneuk/material-about-library开源编程语言(OpenSource Language):Java 100.0%开源软件介绍(OpenSource Introduction):material-about-libraryMakes it easy to create a beautiful about screen for your app. Generates an Idea from here: Heinrich Reimer's open-source-library-request-manager Design inspired by Phonograph If you use this library in your app, please let me know and I'll add it to the list. DemoScreenshots
Features
Dependencymaterial-about-library is available on jitpack.io. Gradle dependency: allprojects {
repositories {
maven { url 'https://jitpack.io' }
}
} dependencies {
implementation 'com.github.daniel-stoneuk:material-about-library:3.1.2'
} Help test dependencies {
implementation 'com.github.daniel-stoneuk:material-about-library:3.2.0-rc01'
} MigrationView the migration guide here SetupActivityYour public class ExampleMaterialAboutActivity extends MaterialAboutActivity {
@Override
@NonNull
protected MaterialAboutList getMaterialAboutList(@NonNull Context context) {
return new MaterialAboutList.Builder()
.build(); // This creates an empty screen, add cards with .addCard()
}
@Override
protected CharSequence getActivityTitle() {
return getString(R.string.mal_title_about);
}
} Ensure that the theme extends a <manifest ...>
<application ...>
<activity android:name=".ExampleMaterialAboutActivity"
android:theme="@style/AppTheme.MaterialAboutActivity"/>
</application>
</manifest> <style name="AppTheme.MaterialAboutActivity" parent="Theme.MaterialComponents.DayNight.DarkActionBar">
<item name="colorPrimary">@color/colorPrimary</item>
<item name="colorPrimaryDark">@color/colorPrimaryDark</item>
</style> FragmentYour public class ExampleMaterialAboutFragment extends MaterialAboutFragment {
@Override
protected MaterialAboutList getMaterialAboutList(final Context activityContext) {
return new MaterialAboutList.Builder()
.build(); // This creates an empty screen, add cards with .addCard()
}
} Theming will follow the activity theme. Add Cards:Start building a "card" using public class ExampleMaterialAboutActivity extends MaterialAboutActivity {
@Override
@NonNull
protected MaterialAboutList getMaterialAboutList(@NonNull Context context) {
MaterialAboutCard card = new MaterialAboutCard.Builder()
// Configure card here
.build();
return new MaterialAboutList.Builder()
.addCard(card)
.build();
}
} Give the card a title by calling MaterialAboutCard card = new MaterialAboutCard.Builder()
.title("Author")
.build(); Enable elevation and disable the outline to get a more classic design by calling MaterialAboutCard card = new MaterialAboutCard.Builder()
.outline(false)
.build(); Add Items to a card:There are currently two types of items you can add to a card -
MaterialAboutCard.Builder cardBuilder = new MaterialAboutCard.Builder();
cardBuilder.addItem(new MaterialAboutTitleItem.Builder()
.text("Material About Library")
.icon(R.mipmap.ic_launcher)
.build());
cardBuilder.addItem(new MaterialAboutActionItem.Builder()
.text("Version")
.subText("1.0.0")
.icon(R.drawable.ic_about_info)
.setOnClickAction(new MaterialAboutActionItem.OnClickAction() {
@Override
public void onClick() {
Toast.makeText(ExampleMaterialAboutActivity.this, "Version Tapped", Toast.LENGTH_SHORT)
.show();
}
})
.build()); Return the list:Create a MaterialAboutCard card = new MaterialAboutCard.Builder()
.title("Hey! I'm a card")
.build();
return new MaterialAboutList.Builder()
.addCard(card)
.build(); Check out a working example in Tip: You can either use Strings / Drawables or Resources when creating Tip: Use Android-Iconics for icons. "Android-Iconics - Use any icon font, or vector (.svg) as drawable in your application." Tip: Use ConvenienceBuilder to easily create items or OnClickActions. Tip: Customise text colour and card colour in your styles. Example below: <style name="AppTheme.MaterialAboutActivity.Light.DarkActionBar.CustomCardView" parent="Theme.MaterialComponents.Light.DarkActionBar">
<!-- Customize your theme here. -->
<item name="colorPrimary">@color/colorPrimary</item>
<item name="colorPrimaryDark">@color/colorPrimaryDark</item>
<item name="android:textColorPrimary">#ffffff</item>
<item name="android:textColorSecondary">#ffffff</item>
<item name="colorSurface">@color/colorPrimaryDark</item>
<item name="colorOnSurface">#ffffff</item>
</style> Custom Adapters:It is possible to replace the contents of a card with a custom adapter. If you do this, then none of the items associated with the card will be displayed. Check out the demo app, in which use LicenseAdapter (hence the INTERNET permission). MaterialAboutCard.Builder customAdapterCardBuilder = new MaterialAboutCard.Builder();
// Create list of libraries
List<Library> libraries = new ArrayList<>();
// Add libraries that are hosted on GitHub with an Apache v2 license.
libraries.add(Licenses.fromGitHubApacheV2("yshrsmz/LicenseAdapter"));
libraries.add(Licenses.fromGitHubApacheV2("daniel-stoneuk/material-about-library"));
customAdapterCardBuilder.title("Custom Adapter (License Adapter)");
customAdapterCardBuilder.customAdapter(new LicenseAdapter(libraries));
}); Dynamic items:It's possible to create dynamic items that either change on tap (or when any other event occurs). There are two examples in the sample application. Simply change the items in the list variable and then call final MaterialAboutActionItem item = new MaterialAboutActionItem.Builder()
.text("Dynamic UI")
.subText(subText)
.icon(new IconicsDrawable(c)
.icon(CommunityMaterial.Icon.cmd_refresh)
.color(ContextCompat.getColor(c, R.color.mal_color_icon_dark_theme)
).sizeDp(18))
.build();
item.setOnClickAction(new MaterialAboutItemOnClickAction() {
@Override
public void onClick() {
item.setSubText("Random number: " + ((int) (Math.random() * 10)));
refreshMaterialAboutList();
}
}); Custom card and Action layoutTo get a layout that is similar to the 6th screenshot above simply override the files Contributors
Apps using this library
License
|
2023-10-27
2022-08-15
2022-08-17
2022-09-23
2022-08-13
请发表评论