android.widget.Space Java Examples

The following examples show how to use android.widget.Space. 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: HeadsUpBase.java    From HeadsUp with GNU General Public License v2.0 6 votes vote down vote up
/**
 * Adds empty space view to {@link #mHolder#containerView container} for a
 * short {@link #LAYOUT_ANIMATION_TIME}. This uses {@link #mHandler}!
 *
 * @param height height of space view in pixels.
 */
private void addSpaceToContainer(final int height) {
    final Space space = new Space(mHolder.context);
    final ViewGroup.LayoutParams lp = new LinearLayout.LayoutParams(0, height);
    mHolder.containerView.addView(space, lp);
    mHolder.containerOffset++;

    // Remove space view after a while.
    mHandler.postDelayed(new Runnable() {
        @Override
        public void run() {
            mHolder.containerView.removeView(space);
            mHolder.containerOffset--;
        }
    }, LAYOUT_ANIMATION_TIME);
}
 
Example #2
Source File: SingleImageView.java    From Tangram-Android with MIT License 6 votes vote down vote up
private void initUI(Context context, int size){
    setOrientation(VERTICAL);
    setGravity(Gravity.CENTER_HORIZONTAL);
    setBackgroundColor(Color.WHITE);

    icon = new ImageView(context);
    icon.setScaleType(ImageView.ScaleType.CENTER_CROP);

    LayoutParams iconLp = new LayoutParams(size, size);
    iconLp.topMargin = Style.dp2px(8);
    addView(icon, iconLp);

    titleTextView = new TextView(context);
    titleTextView.setTextSize(TypedValue.COMPLEX_UNIT_DIP, 12);
    LayoutParams titleLp = new LayoutParams(ViewGroup.LayoutParams.WRAP_CONTENT,
            ViewGroup.LayoutParams.WRAP_CONTENT);
    titleLp.topMargin = Style.dp2px(4.0);
    addView(titleTextView, titleLp);

    Space space = new Space(context);
    LayoutParams spaceLp = new LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT,
            Style.dp2px(8));
    addView(space, spaceLp);
}
 
Example #3
Source File: TestImageView.java    From Tangram-Android with MIT License 6 votes vote down vote up
private void initUI(Context context, int size) {
    setOrientation(VERTICAL);
    setGravity(Gravity.CENTER_HORIZONTAL);
    setBackgroundColor(Color.WHITE);

    icon = new ImageView(context);
    icon.setScaleType(ImageView.ScaleType.CENTER_CROP);

    LayoutParams iconLp = new LayoutParams(size, size);
    iconLp.topMargin = Style.dp2px(8);
    addView(icon, iconLp);

    titleTextView = new TextView(context);
    titleTextView.setTextSize(TypedValue.COMPLEX_UNIT_DIP, 12);
    LayoutParams titleLp = new LayoutParams(ViewGroup.LayoutParams.WRAP_CONTENT,
            ViewGroup.LayoutParams.WRAP_CONTENT);
    titleLp.topMargin = Style.dp2px(4.0);
    addView(titleTextView, titleLp);

    Space space = new Space(context);
    LayoutParams spaceLp = new LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT,
            Style.dp2px(8));
    addView(space, spaceLp);
}
 
Example #4
Source File: AlertController.java    From ticdesign with Apache License 2.0 5 votes vote down vote up
public void setup(Window window,
                  @IdRes int textButtonId, @IdRes int textSpaceId,
                  @IdRes int iconButtonId) {
    textButton = (Button) window.findViewById(textButtonId);
    textSpace = (Space) window.findViewById(textSpaceId);
    iconButton = (FloatingActionButton) window.findViewById(iconButtonId);
}
 
Example #5
Source File: MainActivity.java    From road-trip with Apache License 2.0 5 votes vote down vote up
private void finishLoadingPhotos() {
    mIntroView.stopWaitAnimation();

    LinearLayout container = (LinearLayout) findViewById(R.id.container);
    LayoutInflater inflater = getLayoutInflater();

    Space spacer = new Space(this);
    spacer.setLayoutParams(new LinearLayout.LayoutParams(LinearLayout.LayoutParams.MATCH_PARENT,
            findViewById(R.id.scroller).getHeight()));
    container.addView(spacer);

    for (State s : mStates) {
        addState(inflater, container, s);
    }
}
 
Example #6
Source File: PojoGroupBasicAdapter.java    From Tangram-Android with MIT License 5 votes vote down vote up
@Override
public <V extends View> BinderViewHolder<BaseCell, V> createViewHolder(@NonNull ControlBinder<BaseCell, V> binder,
                                                                       @NonNull Context context, ViewGroup parent,
                                                                       String cellType) {
    V view;
    if (binder != null) {
        view = binder.createView(context, parent, mMvHelper.renderManager().getComponentInfo(cellType));
    } else {
        view = (V) new Space(context);
    }
    return new BinderViewHolder<>(view, binder);
}
 
Example #7
Source File: ViewTemplateNoop.java    From under-the-hood with Apache License 2.0 4 votes vote down vote up
@Override
public View constructView(ViewGroup parent, LayoutInflater inflater) {
    return new Space(parent.getContext());
}
 
Example #8
Source File: BaseRecyclerViewAdapter.java    From FriendCircle with GNU General Public License v3.0 4 votes vote down vote up
protected BaseRecyclerViewHolder createEmptyHolder() {
    return new EmptyHolder(new Space(mContext));
}
 
Example #9
Source File: AnimationListDemoScene.java    From scene with Apache License 2.0 4 votes vote down vote up
private void addSpace(LinearLayout parent, int height) {
    Space space = new Space(getActivity());
    parent.addView(space, ViewGroup.LayoutParams.MATCH_PARENT, height);
}
 
Example #10
Source File: TabularContextMenuListAdapter.java    From 365browser with Apache License 2.0 4 votes vote down vote up
@Override
public View getView(int position, View convertView, ViewGroup parent) {
    ContextMenuItem menuItem = mMenuItems.get(position);
    ViewHolderItem viewHolder;

    if (convertView == null) {
        LayoutInflater inflater = LayoutInflater.from(mActivity);
        convertView = inflater.inflate(R.layout.tabular_context_menu_row, null);

        viewHolder = new ViewHolderItem();
        viewHolder.mIcon = (ImageView) convertView.findViewById(R.id.context_menu_icon);
        viewHolder.mText = (TextView) convertView.findViewById(R.id.context_text);
        viewHolder.mShareIcon =
                (ImageView) convertView.findViewById(R.id.context_menu_share_icon);
        viewHolder.mRightPadding =
                (Space) convertView.findViewById(R.id.context_menu_right_padding);

        convertView.setTag(viewHolder);
    } else {
        viewHolder = (ViewHolderItem) convertView.getTag();
    }

    viewHolder.mText.setText(menuItem.getTitle(mActivity));
    Drawable icon = menuItem.getDrawable(mActivity);
    viewHolder.mIcon.setImageDrawable(icon);
    viewHolder.mIcon.setVisibility(icon != null ? View.VISIBLE : View.INVISIBLE);

    if (menuItem == ChromeContextMenuItem.SHARE_IMAGE) {
        Intent shareIntent = ShareHelper.getShareImageIntent(null);
        final Pair<Drawable, CharSequence> shareInfo =
                ShareHelper.getShareableIconAndName(mActivity, shareIntent);
        if (shareInfo.first != null) {
            viewHolder.mShareIcon.setImageDrawable(shareInfo.first);
            viewHolder.mShareIcon.setVisibility(View.VISIBLE);
            viewHolder.mShareIcon.setContentDescription(mActivity.getString(
                    R.string.accessibility_menu_share_via, shareInfo.second));
            viewHolder.mShareIcon.setOnClickListener(new View.OnClickListener() {
                @Override
                public void onClick(View view) {
                    mOnDirectShare.run();
                }
            });
            viewHolder.mRightPadding.setVisibility(View.GONE);
        }
    } else {
        viewHolder.mShareIcon.setVisibility(View.GONE);
        viewHolder.mRightPadding.setVisibility(View.VISIBLE);
    }

    return convertView;
}
 
Example #11
Source File: DSL.java    From anvil with MIT License 4 votes vote down vote up
public static BaseDSL.ViewClassResult space() {
  return BaseDSL.v(Space.class);
}
 
Example #12
Source File: DSL.java    From anvil with MIT License 4 votes vote down vote up
public static Void space(Anvil.Renderable r) {
  return BaseDSL.v(Space.class, r);
}
 
Example #13
Source File: DSL.java    From anvil with MIT License 4 votes vote down vote up
public static BaseDSL.ViewClassResult space() {
  return BaseDSL.v(Space.class);
}
 
Example #14
Source File: DSL.java    From anvil with MIT License 4 votes vote down vote up
public static Void space(Anvil.Renderable r) {
  return BaseDSL.v(Space.class, r);
}
 
Example #15
Source File: MeasurementView.java    From openScale with GNU General Public License v3.0 4 votes vote down vote up
private void initView(Context context) {
    measurementRow = new TableRow(context);

    iconView = new ImageView(context);
    iconViewBackground = new GradientDrawable();
    nameView = new TextView(context);
    valueView = new TextView(context);
    editModeView = new ImageView(context);
    indicatorView = new ImageView(context);

    evaluatorRow = new TableRow(context);
    evaluatorView = new LinearGaugeView(context);

    incDecLayout = new LinearLayout(context);

    measurementRow.setLayoutParams(new TableRow.LayoutParams(LayoutParams.MATCH_PARENT,LayoutParams.WRAP_CONTENT, 1.0f));
    measurementRow.setGravity(Gravity.CENTER);
    measurementRow.addView(iconView);
    measurementRow.addView(nameView);
    measurementRow.addView(valueView);
    measurementRow.addView(incDecLayout);
    measurementRow.addView(editModeView);
    measurementRow.addView(indicatorView);

    addView(measurementRow);
    addView(evaluatorRow);

    iconViewBackground.setColor(ColorUtil.COLOR_GRAY);
    iconViewBackground.setShape(GradientDrawable.OVAL);
    iconViewBackground.setGradientRadius(iconView.getWidth());

    iconView.setImageResource(iconId);
    iconView.setScaleType(ImageView.ScaleType.CENTER_INSIDE);
    iconView.setPadding(25,25,25,25);

    iconView.setColorFilter(ColorUtil.COLOR_BLACK);
    iconView.setBackground(iconViewBackground);

    TableRow.LayoutParams iconLayout = new TableRow.LayoutParams(LinearLayout.LayoutParams.WRAP_CONTENT, LinearLayout.LayoutParams.WRAP_CONTENT);
    iconLayout.setMargins(10, 5, 10, 5);
    iconView.setLayoutParams(iconLayout);

    nameView.setTextSize(TypedValue.COMPLEX_UNIT_SP, 15);
    nameView.setLines(2);
    nameView.setLayoutParams(new TableRow.LayoutParams(0, LayoutParams.WRAP_CONTENT, 0.55f));

    valueView.setTextSize(TypedValue.COMPLEX_UNIT_SP, 15);
    valueView.setGravity(Gravity.RIGHT | Gravity.CENTER);
    valueView.setPadding(0,0,20,0);
    valueView.setLayoutParams(new TableRow.LayoutParams(0, LayoutParams.WRAP_CONTENT, 0.29f));

    incDecLayout.setOrientation(VERTICAL);
    incDecLayout.setVisibility(View.GONE);
    incDecLayout.setPadding(0,0,0,0);
    incDecLayout.setLayoutParams(new TableRow.LayoutParams(0, LayoutParams.MATCH_PARENT, 0.05f));

    editModeView.setImageDrawable(ContextCompat.getDrawable(context, R.drawable.ic_editable));
    editModeView.setScaleType(ImageView.ScaleType.CENTER_INSIDE);
    editModeView.setVisibility(View.GONE);
    editModeView.setColorFilter(getForegroundColor());

    indicatorView.setLayoutParams(new TableRow.LayoutParams(0, LayoutParams.MATCH_PARENT, 0.01f));
    indicatorView.setBackgroundColor(Color.GRAY);

    evaluatorRow.setLayoutParams(new TableRow.LayoutParams(LayoutParams.MATCH_PARENT,LayoutParams.WRAP_CONTENT, 1.0f));
    evaluatorRow.addView(new Space(context));
    evaluatorRow.addView(evaluatorView);
    Space spaceAfterEvaluatorView = new Space(context);
    evaluatorRow.addView(spaceAfterEvaluatorView);
    evaluatorRow.setVisibility(View.GONE);

    evaluatorView.setLayoutParams(new TableRow.LayoutParams(0, LayoutParams.WRAP_CONTENT, 0.99f));
    spaceAfterEvaluatorView.setLayoutParams(new TableRow.LayoutParams(0, LayoutParams.WRAP_CONTENT, 0.01f));

    setOnClickListener(new onClickListenerEvaluation());
}
 
Example #16
Source File: MultiComponent.java    From Walrus with GNU General Public License v3.0 4 votes vote down vote up
public static View createSpacer(Context context) {
    Space space = new Space(context);
    space.setMinimumHeight((int) TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_DIP,
            MultiComponent.VERTICAL_SPACE_DP, space.getResources().getDisplayMetrics()));
    return space;
}
 
Example #17
Source File: CaseListDemo.java    From scene with Apache License 2.0 4 votes vote down vote up
private void addSpace(LinearLayout parent, int height) {
    Space space = new Space(getActivity());
    parent.addView(space, ViewGroup.LayoutParams.MATCH_PARENT, height);
}