/** Initialize the Views and GUI widgets. */ private void initializeViews() { LayoutInflater inflater = (LayoutInflater) getContext().getSystemService(Context.LAYOUT_INFLATER_SERVICE); LinearLayout view = (LinearLayout) inflater.inflate(R.layout.material_spinner_layout, this, true); containerFrameLayout = (FrameLayout) view.getChildAt(0); materialSpinner = (MaterialSpinner) containerFrameLayout.getChildAt(0); triangleShape = (TriangleShape) containerFrameLayout.getChildAt(1); lineView = containerFrameLayout.getChildAt(2); if (initializedByParsing) { // Spinner materialSpinner.setTextSize(textSize); materialSpinner.setTextColor(textColor); materialSpinner.setBackgroundColor(backgroundColor); materialSpinner.setVisibleItemNumber(visibleItems); materialSpinner.setVerticalItemsOffset(itemsOverSpinner); triangleShape.setColor(arrowColor); if (backgroundDrawable != null) materialSpinner.setBackground(backgroundDrawable); if (typeface != null) materialSpinner.setTypeFace(typeface); setArrowColor(arrowColor); setLineColor(lineColor); setMode(mode); // Item materialSpinner.setItemTextSize(itemTextSize); materialSpinner.setItemTextColor(itemTextColor); materialSpinner.setItemBackgroundColor(itemSelectedColor); materialSpinner.setItemBackgroundDrawable(itemSelectedDrawable); // List materialSpinner.setPopUpBackgroundColor(listBackgroundColor); materialSpinner.setPopupBackgroundDrawable(listBackgroundDrawable); } }
/** * Set spinner mode * * @param mode - mode of field (text, button, simple) */ public void setMode(Mode mode) { switch (mode) { case TEXT: lineView.setVisibility(VISIBLE); break; case BUTTON: lineView.setVisibility(GONE); break; case SIMPLE: lineView.setVisibility(GONE); triangleShape.setVisibility(GONE); break; } }
/** * Set arrow color * * @param color - color code */ public void setArrowColor(int color) { triangleShape.setColor(color); }