private void initBarButtons() { final LinearLayout.LayoutParams llButtonParams = new LinearLayout.LayoutParams(buttonWidth, buttonWidth); llButtonParams.setMargins(0, 0, buttonMargin, 0); undoButton.setBackgroundResource(R.drawable.undo_button_selector); undoButton.setPadding(0, 0, 0, 0); undoButton.setLayoutParams(llButtonParams); this.addView(undoButton); redoButton.setBackgroundResource(R.drawable.redo_button_selector); redoButton.setPadding(0, 0, 0, 0); redoButton.setLayoutParams(llButtonParams); this.addView(redoButton); // Tool radio group LayoutParams radioGroupParams = new LayoutParams(LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT); radioGroupParams.setMargins(0, 0, 0, 0); final RadioGroup toolRadioGroup = new RadioGroup(this.getContext()); toolRadioGroup.setOrientation(RadioGroup.HORIZONTAL); toolRadioGroup.setLayoutParams(radioGroupParams); toolRadioGroup.setPadding(0, 0, 0, 0); final RadioGroup.LayoutParams rgButtonParams = new RadioGroup.LayoutParams(buttonWidth, buttonWidth); rgButtonParams.setMargins(0, 0, buttonMargin, 0); selectButton.setButtonDrawable(R.drawable.select_button_selector); selectButton.setLayoutParams(rgButtonParams); toolRadioGroup.addView(selectButton); eraserButton.setButtonDrawable(R.drawable.erase_button_selector); eraserButton.setLayoutParams(rgButtonParams); toolRadioGroup.addView(eraserButton); for (int i = 0; i < 8; i++) { penButtons[i] = new PenRadioButton(this.getContext()); penButtons[i].setLayoutParams(rgButtonParams); toolRadioGroup.addView(penButtons[i]); } this.addView(toolRadioGroup); menuButtonSpacer.setLayoutParams( new LinearLayout.LayoutParams(0, LayoutParams.MATCH_PARENT, 1.0f)); this.addView(menuButtonSpacer); menuButton.setBackgroundResource(R.drawable.ic_action_overflow); menuButton.setPadding(0, 0, 0, 0); menuButton.setLayoutParams(llButtonParams); menuButton.setOnClickListener(menuButtonListener); this.addView(menuButton); }
/** * Creates the new RadioGroup based on the Input Type of current LogItem * * @param options */ public void createRadioGroup(ArrayList<String> options) { RelativeLayout.LayoutParams params = new RelativeLayout.LayoutParams( RelativeLayout.LayoutParams.MATCH_PARENT, RelativeLayout.LayoutParams.WRAP_CONTENT); params.addRule(RelativeLayout.BELOW, R.id.LogItemName); group = new RadioGroup(this.getContext()); group.setLayoutParams(params); for (int i = 0; i < options.size(); i++) { RadioButton btn = new RadioButton(this.getContext()); btn.setId(i); btn.setText(options.get(i)); group.addView(btn); } group.setGravity(Gravity.CENTER_HORIZONTAL); rlayout.addView(group); // Todo: create Listener to add to database when input. }