/** Config UI just one time */ private void configUI() { setOrientation(LinearLayout.VERTICAL); setPadding(8, 8, 8, 8); TextView titleView = new TextView(ctx); titleView.setText(TEXT_TITLE); titleView.setTextColor(Color.LTGRAY); addView(titleView); LinearLayout subLayout = new LinearLayout(ctx); subLayout.setOrientation(LinearLayout.HORIZONTAL); LinearLayout.LayoutParams subLayoutParams = new LayoutParams(LayoutParams.MATCH_PARENT, LayoutParams.WRAP_CONTENT); // configuring the iconView iconView.setImageDrawable(icon); LayoutParams icParams = new LayoutParams(LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT); icParams.gravity = Gravity.CENTER_VERTICAL; // configuring the msgView msgView.setText(msg); msgView.setPadding(10, 0, 0, 0); msgView.setTextSize(20); msgView.setTextColor(Color.WHITE); msgView.setGravity(Gravity.CENTER_VERTICAL); msgView.setInputType(InputType.TYPE_TEXT_FLAG_NO_SUGGESTIONS); msgView.setMaxLines(1); LayoutParams tvParams = new LayoutParams(LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT); subLayout.addView(iconView, icParams); subLayout.addView(msgView, tvParams); addView(subLayout, subLayoutParams); actionBtn.setText(TEXT_DELETE); actionBtn.setTextColor(Color.WHITE); addView(actionBtn, new LayoutParams(LayoutParams.MATCH_PARENT, LayoutParams.WRAP_CONTENT)); undoRedoLayout.setOrientation(LinearLayout.HORIZONTAL); undoView = new ImageView(ctx); redoView = new ImageView(ctx); undoView.setImageDrawable(DrawableFactory.build(ctx, DrawableFactory.ICON_UNDO)); redoView.setImageDrawable(DrawableFactory.build(ctx, DrawableFactory.ICON_REDO)); undoView.setClickable(true); redoView.setClickable(true); LayoutParams undoRedoParams = new LayoutParams(LayoutParams.MATCH_PARENT, LayoutParams.WRAP_CONTENT); undoRedoParams.weight = 1; undoRedoLayout.addView(undoView, undoRedoParams); undoRedoLayout.addView(redoView, undoRedoParams); addView(undoRedoLayout); }