-
Notifications
You must be signed in to change notification settings - Fork 140
Getting Started
Your Activity
must extend MaterialAboutActivity
and be in your AndroidManifest.xml:
public class ExampleMaterialAboutActivity extends MaterialAboutActivity {
@Override
protected MaterialAboutList getMaterialAboutList(Context context) {
return new MaterialAboutList.Builder()
.build();
}
@Override
protected CharSequence getActivityTitle() {
return getString(R.string.mal_title_about);
}
}
Ensure that the theme extends 'Theme.Mal', and apply primary & accent colours.
<manifest ...>
<application ...>
<activity android:name=".ExampleMaterialAboutActivity"
android:theme="@style/AppTheme.MaterialAboutActivity"/>
</application>
</manifest>
<style name="AppTheme.MaterialAboutActivity" parent="Theme.Mal" >
<!-- Customize your theme here. -->
<item name="colorPrimary">@color/colorPrimary</item>
<item name="colorPrimaryDark">@color/colorPrimaryDark</item>
<item name="colorAccent">@color/colorAccent</item>
</style>
Your fragment
must extend MaterialAboutFragment
.
public class ExampleMaterialAboutFragment extends MaterialAboutFragment {
@Override
protected MaterialAboutList getMaterialAboutList(final Context activityContext) {
}
}
Start building a "card" using [MaterialAboutCard.Builder()
][8]
public class ExampleMaterialAboutActivity extends MaterialAboutActivity {
@Override
protected MaterialAboutList getMaterialAboutList() {
MaterialAboutCard.Builder appCardBuilder = new MaterialAboutCard.Builder();
Give the card a title by calling .title
on the Builder
authorCardBuilder.title("Author");
There are currently two types of item you can add to a card - MaterialAboutTitleItem
and MaterialAboutActionItem
. Planned items include "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 (eg app icon) and larger text.
MaterialAboutTitleItem
is created with MaterialAboutTitleItem.Builder()
and lets you specify text and an icon.
appCardBuilder.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 OnClickListener.
appCardBuilder.addItem(new MaterialAboutActionItem.Builder()
.text("Version")
.subText("1.0.0")
.icon(R.drawable.ic_about_info)
.setOnClickListener(new MaterialAboutActionItem.OnClickListener() {
@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.
return new MaterialAboutList.Builder()
.addCard(supportCardBuilder.build())
.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 OnClickListeners.