@@ -25,6 +25,7 @@ public class OnboardingFragment extends Fragment implements Serializable {
25
25
private static final String IMAGE_RESOURCE_ID = "IMAGE_RESOURCE_ID" ;
26
26
private static final String POSITION = "POSITION" ;
27
27
private static final String BUTTON_TEXT = "BUTTON_TEXT" ;
28
+ private static final String MAX_IMAGE_HEIGHT = "MAX_IMAGE_HEIGHT" ;
28
29
29
30
public OnboardingFragment () {
30
31
// Required empty public constructor
@@ -40,6 +41,7 @@ public static OnboardingFragment newInstance(OnboardingPage onboardingPage, int
40
41
args .putString (BUTTON_TEXT , onboardingPage .getButtonText ());
41
42
args .putInt (TITLE_TEXT_COLOR , onboardingPage .getTitleTextColor ());
42
43
args .putInt (BODY_TEXT_COLOR ,onboardingPage .getBodyTextColor ());
44
+ args .putInt (MAX_IMAGE_HEIGHT , onboardingPage .getMaxImageHeight ());
43
45
fragment .setArguments (args );
44
46
return fragment ;
45
47
}
@@ -62,6 +64,8 @@ public View onCreateView(LayoutInflater inflater, ViewGroup container,
62
64
final int position = bundle .getInt (POSITION , 0 );
63
65
/* The button text (if the user set any) */
64
66
String buttonText = bundle .getString (BUTTON_TEXT , null );
67
+ /* Max height for the image (if not, it just scales it up) */
68
+ int maxImageHeight = bundle .getInt (MAX_IMAGE_HEIGHT ,-1 );
65
69
66
70
@ ColorRes int titleTextColor = bundle .getInt (TITLE_TEXT_COLOR , -1 );
67
71
@ ColorRes int bodyTextColor = bundle .getInt (BODY_TEXT_COLOR ,-1 );
@@ -96,6 +100,10 @@ public View onCreateView(LayoutInflater inflater, ViewGroup container,
96
100
//Set the image
97
101
if (imageResId !=-1 ) {
98
102
imageView .setImageResource (imageResId );
103
+ //Set the max image height (if it was set)
104
+ if (maxImageHeight !=-1 ) {
105
+ imageView .setMaxHeight (maxImageHeight );
106
+ }
99
107
} else {
100
108
imageView .setVisibility (View .GONE );
101
109
}
0 commit comments