Makes it easy to create a beautiful about screen for your app. Generates an Activity
or Fragment
.
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.
Light | Dark | Custom Cardview Background |
---|---|---|
material-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 3.2.0
with shared views between adapters (may cause crashes):
dependencies {
implementation 'com.github.daniel-stoneuk:material-about-library:3.2.0-rc01'
}
View the migration guide here
Your Activity
must extend MaterialAboutActivity
and be in your AndroidManifest.xml:
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 MaterialComponents
theme, and apply primary & secondary colours:
<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>
Your Fragment
must extend MaterialAboutFragment
.
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.
Start building a "card" using MaterialAboutCard.Builder()
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 .title()
on the MaterialAboutCard.Builder
MaterialAboutCard card = new MaterialAboutCard.Builder()
.title("Author")
.build();
Enable elevation and disable the outline to get a more classic design by calling .outline(false)
on the MaterialAboutCard.Builder
MaterialAboutCard card = new MaterialAboutCard.Builder()
.outline(false)
.build();
There are currently two types of items you can add to a card - MaterialAboutTitleItem
and MaterialAboutActionItem
. Other types of items are planned, for example "person" items which feature buttons to showcase a single person. Feel free to submit a PR or Issue for more item ideas.
MaterialAboutActionItem
: Standard item with text, icon and optional subtext.MaterialAboutTitleItem
: Larger item with large icon (e.g. app icon) and larger text.MaterialAboutTitleItem
is created with MaterialAboutTitleItem.Builder()
and lets you specify text and an icon.
MaterialAboutCard.Builder cardBuilder = new MaterialAboutCard.Builder();
cardBuilder.addItem(new MaterialAboutTitleItem.Builder()
.text("Material About Library")
.icon(R.mipmap.ic_launcher)
.build());
MaterialAboutActionItem
is created with MaterialAboutActionItem.Builder()
and lets you specify text, sub-text, an icon and an OnClickAction.
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());
Create a MaterialAboutList
using MaterialAboutList.Builder()
, passing in the cards you would like to display.
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 Demo.java
.
Tip: You can either use Strings / Drawables or Resources when creating MaterialAboutItem
's
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>
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));
});
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 refreshMaterialAboutList()
. DiffUtil calculates the changes to animate in the RecyclerView.
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();
}
});
To get a layout that is similar to the 6th screenshot above simply override the files mal_material_about_action_item
and mal_material_about_list_card
by creating new layout resources with the same filename. See here.
Copyright 2016-2020 Daniel Stone
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
添加依赖:compile 'com.android.support:design:25.1.0' 介绍 Snackbar提供了一个介于Toast和AlertDialog之间轻量级控件,它可以很方便的提供消息的提示和动作反馈。Snackbar的使用与Toast的使用基本相同。用于在界面下面提示一些关键信息,跟Toast不同的地方是SnackBar允许用户向右滑动消除它,同时,也允许在SnackBar
Cloudadc is an open community that focuses on the exploration and best implementation of distributed architecture, cloud-native applications, and cloud-native application delivery control. How to Cont
Flarum is a delightfully simple discussion platform for your website. It's fast, free, and easy to use, with all the features you need to run a successful community. It's also extremely extensible, al
Python Tutorial This document was generated using the LaTeX2HTML translator. LaTeX2HTML is Copyright © 1993, 1994, 1995, 1996, 1997, Nikos Drakos, Computer Based Learning Unit, University of Leeds, an
JSON API 来自 JSON 的数据传输,它被隐式地定义在 Ember 的 REST 风格数据适配器。 一般来说,Ember Data 被设计用来实现这样的目的:消除哪些为不同应用程序与服务器之间通信而写的特殊代码, 而是用 REST 风格数据适配器将它们转换成统一的方式。 一些服务器,比如 Firebase、Parse 和 CouchDB 已经定义了和客户端通信的精确的协议,以便适合 Emb
Android About Page Create an awesome About Page for your Android App in 2 minutes This library allows to generate beautiful About Pages with less effort, it's fully customizable and supports opening s
취준생이 반드시 알아야 할 프론트엔드 지식들 목차 소개 프론트엔드 전반 HTML CSS Javascript 네트워크 보안 �� 소개 취업 전 반드시 알아야 한다고 생각하는 프론트엔드 분야의 기초지식들을 모아놓았습니다. 실제 면접질문들과 구글링을 통해 검색한 필수지식 및 질문들을 통해서 하나하나 정리했습니다. 기초지식을 너무 얕게 혹은 너무 깊게 말고 적당한