Java Code Examples for android.widget.LinearLayout#MarginLayoutParams

The following examples show how to use android.widget.LinearLayout#MarginLayoutParams . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: IntegerQuestionBody.java    From ResearchStack with Apache License 2.0 5 votes vote down vote up
@Override
public View getBodyView(int viewType, LayoutInflater inflater, ViewGroup parent) {
    this.viewType = viewType;

    View view = getViewForType(viewType, inflater, parent);

    Resources res = parent.getResources();
    LinearLayout.MarginLayoutParams layoutParams = new LinearLayout.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT,
            ViewGroup.LayoutParams.WRAP_CONTENT);
    layoutParams.leftMargin = res.getDimensionPixelSize(R.dimen.rsb_margin_left);
    layoutParams.rightMargin = res.getDimensionPixelSize(R.dimen.rsb_margin_right);
    view.setLayoutParams(layoutParams);

    return view;
}
 
Example 2
Source File: DurationQuestionBody.java    From ResearchStack with Apache License 2.0 5 votes vote down vote up
@Override
public View getBodyView(int viewType, LayoutInflater inflater, ViewGroup parent) {
    this.viewType = viewType;

    View view = getViewForType(viewType, inflater, parent);

    Resources res = parent.getResources();
    LinearLayout.MarginLayoutParams layoutParams = new LinearLayout.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT,
            ViewGroup.LayoutParams.WRAP_CONTENT);
    layoutParams.leftMargin = res.getDimensionPixelSize(R.dimen.rsb_margin_left);
    layoutParams.rightMargin = res.getDimensionPixelSize(R.dimen.rsb_margin_right);
    view.setLayoutParams(layoutParams);

    return view;
}
 
Example 3
Source File: MultiChoiceQuestionBody.java    From ResearchStack with Apache License 2.0 5 votes vote down vote up
@Override
public View getBodyView(int viewType, LayoutInflater inflater, ViewGroup parent) {
    View view = getViewForType(viewType, inflater, parent);

    Resources res = parent.getResources();
    LinearLayout.MarginLayoutParams layoutParams = new LinearLayout.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT,
            ViewGroup.LayoutParams.WRAP_CONTENT);
    layoutParams.leftMargin = res.getDimensionPixelSize(R.dimen.rsb_margin_left);
    layoutParams.rightMargin = res.getDimensionPixelSize(R.dimen.rsb_margin_right);
    view.setLayoutParams(layoutParams);

    return view;
}
 
Example 4
Source File: SingleChoiceQuestionBody.java    From ResearchStack with Apache License 2.0 5 votes vote down vote up
@Override
public View getBodyView(int viewType, LayoutInflater inflater, ViewGroup parent) {
    View view = getViewForType(viewType, inflater, parent);

    Resources res = parent.getResources();
    LinearLayout.MarginLayoutParams layoutParams = new LinearLayout.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT,
            ViewGroup.LayoutParams.WRAP_CONTENT);
    layoutParams.leftMargin = res.getDimensionPixelSize(R.dimen.rsb_margin_left);
    layoutParams.rightMargin = res.getDimensionPixelSize(R.dimen.rsb_margin_right);
    view.setLayoutParams(layoutParams);

    return view;
}
 
Example 5
Source File: DecimalQuestionBody.java    From ResearchStack with Apache License 2.0 5 votes vote down vote up
@Override
public View getBodyView(int viewType, LayoutInflater inflater, ViewGroup parent) {
    this.viewType = viewType;

    View view = getViewForType(viewType, inflater, parent);

    Resources res = parent.getResources();
    LinearLayout.MarginLayoutParams layoutParams = new LinearLayout.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT,
            ViewGroup.LayoutParams.WRAP_CONTENT);
    layoutParams.leftMargin = res.getDimensionPixelSize(R.dimen.rsb_margin_left);
    layoutParams.rightMargin = res.getDimensionPixelSize(R.dimen.rsb_margin_right);
    view.setLayoutParams(layoutParams);

    return view;
}
 
Example 6
Source File: CommentListAdapter.java    From Jager with GNU General Public License v3.0 5 votes vote down vote up
@Override
public void onBindViewHolder (CommentsViewHolder holder, int position) {
	Comment comment = mComments.get (position);
	LinearLayout.MarginLayoutParams params = (LinearLayout.MarginLayoutParams) holder
			.commentLayout.getLayoutParams ();
	params.setMargins (comment.getLevel () * 30, 0, 0, 0);
	holder.commentLayout.setLayoutParams (params);
	loadComment (holder, position);
}
 
Example 7
Source File: DateQuestionBody.java    From ResearchStack with Apache License 2.0 4 votes vote down vote up
@Override
public View getBodyView(int viewType, LayoutInflater inflater, ViewGroup parent) {
    View view = inflater.inflate(R.layout.rsb_item_date_view, parent, false);

    TextView title = (TextView) view.findViewById(R.id.label);
    if (viewType == VIEW_TYPE_COMPACT) {
        title.setText(step.getTitle());
    } else {
        title.setVisibility(View.GONE);
    }

    TextView textView = (TextView) view.findViewById(R.id.value);
    textView.setSingleLine(true);
    if (step.getPlaceholder() != null) {
        textView.setHint(step.getPlaceholder());
    } else {
        if (format.getStyle() == AnswerFormat.DateAnswerStyle.Date) {
            textView.setHint(R.string.rsb_hint_step_body_date);
        } else if (format.getStyle() == AnswerFormat.DateAnswerStyle.TimeOfDay) {
            textView.setHint(R.string.rsb_hint_step_body_time);
        } else if (format.getStyle() == AnswerFormat.DateAnswerStyle.DateAndTime) {
            textView.setHint(R.string.rsb_hint_step_body_datetime);
        }
    }

    if (result.getResult() != null) {
        textView.setText(createFormattedResult());
    }

    textView.setOnFocusChangeListener((v, hasFocus) -> {
        if (hasFocus) {
            showDialog(textView);
        }
    });

    textView.setOnClickListener(v -> {
        if (v.isFocused()) {
            showDialog(textView);
        }
    });

    Resources res = parent.getResources();
    LinearLayout.MarginLayoutParams layoutParams = new LinearLayout.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT,
            ViewGroup.LayoutParams.WRAP_CONTENT);
    layoutParams.leftMargin = res.getDimensionPixelSize(R.dimen.rsb_margin_left);
    layoutParams.rightMargin = res.getDimensionPixelSize(R.dimen.rsb_margin_right);
    view.setLayoutParams(layoutParams);

    return view;
}
 
Example 8
Source File: TextQuestionBody.java    From ResearchStack with Apache License 2.0 4 votes vote down vote up
@Override
public View getBodyView(int viewType, LayoutInflater inflater, ViewGroup parent) {
    View body = inflater.inflate(R.layout.rsb_item_edit_text_compact, parent, false);

    editText = (EditText) body.findViewById(R.id.value);
    if (step.getPlaceholder() != null) {
        editText.setHint(step.getPlaceholder());
    } else {
        editText.setHint(R.string.rsb_hint_step_body_text);
    }

    TextView title = (TextView) body.findViewById(R.id.label);

    if (viewType == VIEW_TYPE_COMPACT) {
        title.setText(step.getTitle());
    } else {
        title.setVisibility(View.GONE);
    }

    // Restore previous result
    String stringResult = result.getResult();
    if (!TextUtils.isEmpty(stringResult)) {
        editText.setText(stringResult);
    }

    // Set result on text change
    RxTextView.textChanges(editText).subscribe(text -> {
        result.setResult(text.toString());
    });

    // Format EditText from TextAnswerFormat
    TextAnswerFormat format = (TextAnswerFormat) step.getAnswerFormat();

    editText.setSingleLine(!format.isMultipleLines());

    if (format.getMaximumLength() > TextAnswerFormat.UNLIMITED_LENGTH) {
        InputFilter.LengthFilter maxLengthFilter = new InputFilter.LengthFilter(format.getMaximumLength());
        InputFilter[] filters = ViewUtils.addFilter(editText.getFilters(), maxLengthFilter);
        editText.setFilters(filters);
    }

    Resources res = parent.getResources();
    LinearLayout.MarginLayoutParams layoutParams = new LinearLayout.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT,
            ViewGroup.LayoutParams.WRAP_CONTENT);
    layoutParams.leftMargin = res.getDimensionPixelSize(R.dimen.rsb_margin_left);
    layoutParams.rightMargin = res.getDimensionPixelSize(R.dimen.rsb_margin_right);
    body.setLayoutParams(layoutParams);

    return body;
}