@@ -135,17 +135,17 @@ private void initViews() {
135
135
for (PickerItem pickerItem : items ) {
136
136
if (pickerItem .hasDrawable ()) {
137
137
imageView = new ImageView (getContext ());
138
+ this .addView (imageView );
138
139
imageView .setImageResource (pickerItem .getDrawable ());
139
140
imageView .setScaleType (ImageView .ScaleType .CENTER_INSIDE );
140
141
initStyle (imageView );
141
- this .addView (imageView );
142
142
} else {
143
143
if (pickerItem .getText () != null ) {
144
144
textView = new TextView (getContext ());
145
+ this .addView (textView );
145
146
textView .setGravity (Gravity .CENTER );
146
147
textView .setText (pickerItem .getText ());
147
148
initStyle (textView );
148
- this .addView (textView );
149
149
}
150
150
}
151
151
}
@@ -158,9 +158,10 @@ private void initViews() {
158
158
* @param view
159
159
*/
160
160
private void initStyle (View view ) {
161
- MarginLayoutParams params = new MarginLayoutParams (itemWidth , itemHeight );
161
+ LinearLayout .LayoutParams params = (LayoutParams ) view .getLayoutParams ();
162
+ params .width =itemWidth ;
163
+ params .height =itemHeight ;
162
164
params .setMargins (itemMargin , 0 , itemMargin , 0 );
163
-
164
165
view .setLayoutParams (params );
165
166
view .setBackgroundResource (backgroundSelector );
166
167
if (view instanceof TextView ) {
0 commit comments