Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -215,6 +215,8 @@ public class MaterialIntroView extends RelativeLayout {
*/
private ShapeType shapeType;

private int layoutId = -1;

/**
* Use custom shape
*/
Expand All @@ -225,6 +227,12 @@ public MaterialIntroView(Context context) {
init(context);
}

public MaterialIntroView(Context context, int layoutId) {
super(context);
this.layoutId = layoutId;
init(context);
}

public MaterialIntroView(Context context, AttributeSet attrs) {
super(context, attrs);
init(context);
Expand Down Expand Up @@ -278,12 +286,24 @@ private void init(Context context) {
eraser.setXfermode(new PorterDuffXfermode(PorterDuff.Mode.CLEAR));
eraser.setFlags(Paint.ANTI_ALIAS_FLAG);

View layoutInfo = LayoutInflater.from(getContext()).inflate(R.layout.material_intro_card, null);
if(layoutId <= 0){
layoutId = R.layout.material_intro_card;
}

infoView = layoutInfo.findViewById(R.id.info_layout);
textViewInfo = (TextView) layoutInfo.findViewById(R.id.textview_info);
textViewInfo.setTextColor(colorTextViewInfo);
imageViewIcon = (ImageView) layoutInfo.findViewById(R.id.imageview_icon);
try {
View layoutInfo = LayoutInflater.from(getContext()).inflate(layoutId, null);
infoView = layoutInfo.findViewById(R.id.info_layout);
textViewInfo = (TextView) layoutInfo.findViewById(R.id.textview_info);
textViewInfo.setTextColor(colorTextViewInfo);
imageViewIcon = (ImageView) layoutInfo.findViewById(R.id.imageview_icon);
}
catch(Exception e){
View layoutInfo = LayoutInflater.from(getContext()).inflate(R.layout.material_intro_card, null);
infoView = layoutInfo.findViewById(R.id.info_layout);
textViewInfo = (TextView) layoutInfo.findViewById(R.id.textview_info);
textViewInfo.setTextColor(colorTextViewInfo);
imageViewIcon = (ImageView) layoutInfo.findViewById(R.id.imageview_icon);
}

dotView = LayoutInflater.from(getContext()).inflate(R.layout.dotview, null);
dotView.measure(MeasureSpec.UNSPECIFIED, MeasureSpec.UNSPECIFIED);
Expand Down Expand Up @@ -649,6 +669,11 @@ public Builder(Activity activity) {
materialIntroView = new MaterialIntroView(activity);
}

public Builder(Activity activity, int layoutId) {
this.activity = activity;
materialIntroView = new MaterialIntroView(activity, layoutId);
}

public Builder setMaskColor(int maskColor) {
materialIntroView.setMaskColor(maskColor);
return this;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ public void onClick(View v) {
}

private void showIntro(View view, String usageId, String text){
new MaterialIntroView.Builder(getActivity())
new MaterialIntroView.Builder(getActivity(), R.layout.test_intro_card)
.enableDotAnimation(true)
//.enableIcon(false)
.setFocusGravity(FocusGravity.CENTER)
Expand Down
39 changes: 39 additions & 0 deletions sample/src/main/res/layout/test_intro_card.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
<?xml version="1.0" encoding="utf-8"?>

<RelativeLayout
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:id="@+id/info_layout"
android:layout_width="match_parent"
android:layout_height="wrap_content">

<RelativeLayout
android:id="@+id/layout_info_main"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginBottom="5dp"
android:layout_marginTop="5dp">

<ImageView
android:id="@+id/imageview_icon"
android:layout_width="20dp"
android:layout_height="20dp"
android:layout_centerVertical="true"
android:layout_marginBottom="16dp"
android:layout_marginLeft="16dp"
android:layout_marginTop="16dp"
android:background="@drawable/icon_question" />

<TextView
android:id="@+id/textview_info"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerVertical="true"
android:layout_marginLeft="16dp"
android:layout_marginRight="16dp"
android:layout_toRightOf="@id/imageview_icon"
android:textColor="@android:color/black"
android:textSize="@dimen/info_text_size" />

</RelativeLayout>
</RelativeLayout>