Java 类android.support.v4.widget.Space 实例源码

项目:MVVMFrames    文件:ToastBar.java   
/**
 * 设置TextView上下左右的图片
 *
 * @param left
 * @param top
 * @param right
 * @param bottom
 * @return ToastBar
 */
public ToastBar setCompoundDrawables(Drawable left, Drawable top, Drawable right, Drawable bottom) {
    TextView message = (TextView) snackbar.getView().findViewById(R.id.snackbar_text);
    LinearLayout.LayoutParams paramsMessage = (LinearLayout.LayoutParams) message.getLayoutParams();
    paramsMessage = new LinearLayout.LayoutParams(paramsMessage.width, paramsMessage.height, 0.0f);
    message.setLayoutParams(paramsMessage);
    message.setCompoundDrawablePadding(message.getPaddingLeft());
    int textSize = (int) message.getTextSize();
    if (left != null) {
        left.setBounds(0, 0, textSize, textSize);
    }
    if (right != null) {
        right.setBounds(0, 0, textSize, textSize);
    }
    message.setCompoundDrawables(left, top, right, bottom);
    LinearLayout.LayoutParams paramsSpace = new LinearLayout.LayoutParams(LinearLayout.LayoutParams.WRAP_CONTENT, LinearLayout.LayoutParams.WRAP_CONTENT, 1.0f);
    ((Snackbar.SnackbarLayout) snackbar.getView()).addView(new Space(snackbar.getView().getContext()), 1, paramsSpace);
    return this;
}
项目:PicKing    文件:SnackbarUtils.java   
/**
 * 设置TextView(@+id/snackbar_text)左右两侧的图片
 *
 * @param leftDrawable
 * @param rightDrawable
 * @return
 */
public SnackbarUtils leftAndRightDrawable(@Nullable Drawable leftDrawable, @Nullable Drawable rightDrawable) {
    if (getSnackbar() != null) {
        TextView message = (TextView) getSnackbar().getView().findViewById(R.id.snackbar_text);
        LinearLayout.LayoutParams paramsMessage = (LinearLayout.LayoutParams) message.getLayoutParams();
        paramsMessage = new LinearLayout.LayoutParams(paramsMessage.width, paramsMessage.height, 0.0f);
        message.setLayoutParams(paramsMessage);
        message.setCompoundDrawablePadding(message.getPaddingLeft());
        int textSize = (int) message.getTextSize();
        if (leftDrawable != null) {
            leftDrawable.setBounds(0, 0, textSize, textSize);
        }
        if (rightDrawable != null) {
            rightDrawable.setBounds(0, 0, textSize, textSize);
        }
        message.setCompoundDrawables(leftDrawable, null, rightDrawable, null);
        LinearLayout.LayoutParams paramsSpace = new LinearLayout.LayoutParams(LinearLayout.LayoutParams.WRAP_CONTENT, LinearLayout.LayoutParams.WRAP_CONTENT, 1.0f);
        ((Snackbar.SnackbarLayout) getSnackbar().getView()).addView(new Space(getSnackbar().getView().getContext()), 1, paramsSpace);
    }
    return this;
}
项目:BufferTextInputLayout    文件:BufferTextInputLayout.java   
private void addIndicator(TextView indicator, int index) {
    if (indicatorArea == null) {
        indicatorArea = new LinearLayout(getContext());
        indicatorArea.setOrientation(LinearLayout.HORIZONTAL);
        addView(indicatorArea, LinearLayout.LayoutParams.MATCH_PARENT,
                LinearLayout.LayoutParams.WRAP_CONTENT);
        // Add a flexible spacer in the middle so that the left/right views stay pinned
        final Space spacer = new Space(getContext());
        final LinearLayout.LayoutParams spacerLp = new LinearLayout.LayoutParams(0, 0, 1f);
        indicatorArea.addView(spacer, spacerLp);
        if (editText != null) {
            adjustIndicatorPadding();
        }
    }
    indicatorArea.setVisibility(View.VISIBLE);
    indicatorArea.addView(indicator, index);
    indicatorsAdded++;
}
项目:TruckApp    文件:AbstractDataReceiverListAdapter.java   
@Override
public RecyclerView.ViewHolder onCreateViewHolder(ViewGroup parent, int viewType) {
    switch (viewType) {
        case TYPE_LAST_UPDATED:
            View itemView = LayoutInflater
                    .from(context)
                    .inflate(R.layout.block_lastupdated, parent, false);

            lastUpdatedTextView = (LastUpdatedTextView) itemView.findViewById(R.id.last_updated);

            return new LastUpdatedViewHolder(itemView);

        case TYPE_FOOTER:
            Space emptyView = new Space(context);
            emptyView.setLayoutParams(
                    new ViewGroup.LayoutParams(
                            ViewGroup.LayoutParams.MATCH_PARENT,
                            (int) TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_DIP, 84, context.getResources().getDisplayMetrics())
                    )
            );

            return new EmptyViewHolder(emptyView);
    }

    return null;
}
项目:iosched    文件:TextInputLayout.java   
private void addIndicator(TextView indicator, int index) {
  if (mIndicatorArea == null) {
    mIndicatorArea = new LinearLayout(getContext());
    mIndicatorArea.setOrientation(LinearLayout.HORIZONTAL);
    addView(
        mIndicatorArea,
        LinearLayout.LayoutParams.MATCH_PARENT,
        LinearLayout.LayoutParams.WRAP_CONTENT);

    // Add a flexible spacer in the middle so that the left/right views stay pinned
    final Space spacer = new Space(getContext());
    final LinearLayout.LayoutParams spacerLp = new LinearLayout.LayoutParams(0, 0, 1f);
    mIndicatorArea.addView(spacer, spacerLp);

    if (mEditText != null) {
      adjustIndicatorPadding();
    }
  }
  mIndicatorArea.setVisibility(View.VISIBLE);
  mIndicatorArea.addView(indicator, index);
  mIndicatorsAdded++;
}
项目:commcare-android    文件:EntityViewTile.java   
private void addBuffersToView(Context context, int count, boolean isRow) {
    for (int i = 0; i < count; i++) {
        GridLayout.LayoutParams gridParams;
        if (isRow) {
            gridParams = new GridLayout.LayoutParams(GridLayout.spec(i), GridLayout.spec(0));
            gridParams.width = 1;
            gridParams.height = (int)cellHeight;
        } else {
            gridParams = new GridLayout.LayoutParams(GridLayout.spec(0), GridLayout.spec(i));
            gridParams.width = (int)cellWidth;
            gridParams.height = 1;
        }

        Space space = new Space(context);
        space.setLayoutParams(gridParams);
        this.addView(space, gridParams);
    }
}
项目:AmazingAvatar    文件:MainActivity.java   
private void findViews() {
    mAppBarLayout = (AppBarLayout) findViewById(R.id.app_bar);
    mAvatarImageView = (CircleImageView) findViewById(R.id.imageView_avatar);
    mToolbarTextView = (TextView) findViewById(R.id.toolbar_title);
    mTitleTextView = (TextView) findViewById(R.id.textView_title);
    mSpace = (Space) findViewById(R.id.space);
    mToolBar = (Toolbar) findViewById(R.id.toolbar);
    mRecyclerView = (RecyclerView) findViewById(recyclerView);
}
项目:FinalProject    文件:MessageInput.java   
private void init(Context context) {
    inflate(context, R.layout.view_message_input, this);

    messageInput = (EditText) findViewById(R.id.messageInput);
    messageSendButton = (ImageButton) findViewById(R.id.messageSendButton);
    attachmentButton = (ImageButton) findViewById(R.id.attachmentButton);
    sendButtonSpace = (Space) findViewById(R.id.sendButtonSpace);
    attachmentButtonSpace = (Space) findViewById(R.id.attachmentButtonSpace);

    messageSendButton.setOnClickListener(this);
    attachmentButton.setOnClickListener(this);
    messageInput.addTextChangedListener(this);
    messageInput.setText("");
}
项目:boohee_v5.6    文件:TextInputLayout.java   
private void addIndicator(TextView indicator, int index) {
    if (this.mIndicatorArea == null) {
        this.mIndicatorArea = new LinearLayout(getContext());
        this.mIndicatorArea.setOrientation(0);
        addView(this.mIndicatorArea, -1, -2);
        this.mIndicatorArea.addView(new Space(getContext()), new LinearLayout.LayoutParams(0, 0, 1.0f));
        if (this.mEditText != null) {
            adjustIndicatorPadding();
        }
    }
    this.mIndicatorArea.setVisibility(0);
    this.mIndicatorArea.addView(indicator, index);
    this.mIndicatorsAdded++;
}
项目:QMUI_Android    文件:QMUICommonListItemView.java   
protected void init(Context context, AttributeSet attrs, int defStyleAttr) {
    LayoutInflater.from(context).inflate(R.layout.qmui_common_list_item, this, true);

    TypedArray array = context.obtainStyledAttributes(attrs, R.styleable.QMUICommonListItemView, defStyleAttr, 0);
    @QMUICommonListItemOrientation int orientation = array.getInt(R.styleable.QMUICommonListItemView_qmui_orientation, HORIZONTAL);
    @QMUICommonListItemAccessoryType int accessoryType = array.getInt(R.styleable.QMUICommonListItemView_qmui_accessory_type, ACCESSORY_TYPE_NONE);
    final int initTitleColor = array.getColor(R.styleable.QMUICommonListItemView_qmui_commonList_titleColor, QMUIResHelper.getAttrColor(getContext(), R.attr.qmui_config_color_gray_1));
    final int initDetailColor = array.getColor(R.styleable.QMUICommonListItemView_qmui_commonList_detailColor, QMUIResHelper.getAttrColor(getContext(), R.attr.qmui_config_color_gray_5));
    array.recycle();

    mImageView = (ImageView) findViewById(R.id.group_list_item_imageView);
    mTextContainer = (LinearLayout) findViewById(R.id.group_list_item_textContainer);
    mTextView = (TextView) findViewById(R.id.group_list_item_textView);
    mTextView.setTextColor(initTitleColor);
    mRedDot = (ImageView) findViewById(R.id.group_list_item_tips_dot);
    mNewTipViewStub = (ViewStub) findViewById(R.id.group_list_item_tips_new);
    mDetailTextView = (TextView) findViewById(R.id.group_list_item_detailTextView);
    mTextDetailSpace = (Space) findViewById(R.id.group_list_item_space);
    mDetailTextView.setTextColor(initDetailColor);
    LinearLayout.LayoutParams detailTextViewLP = (LinearLayout.LayoutParams) mDetailTextView.getLayoutParams();
    if (QMUIViewHelper.getIsLastLineSpacingExtraError()) {
        detailTextViewLP.bottomMargin = -QMUIResHelper.getAttrDimen(context, R.attr.qmui_common_list_item_detail_line_space);
    }
    if (orientation == VERTICAL) {
        detailTextViewLP.topMargin = QMUIDisplayHelper.dp2px(getContext(), 6);
    } else {
        detailTextViewLP.topMargin = 0;
    }
    mAccessoryView = (ViewGroup) findViewById(R.id.group_list_item_accessoryView);
    setOrientation(orientation);
    setAccessoryType(accessoryType);
}
项目:good-job    文件:GoodJob.java   
public GoodJob(@NonNull Context context) {
    this.context = context.getApplicationContext();
    handler = new Handler(Looper.getMainLooper());

    contentView = new Space(context);
    duration = DEFAULT_DURATION;
    interpolator = DEFAULT_INTERPOLATOR;
    animation = DEFAULT_ANIMATION;
    onAnimationStartListener = null;
    onAnimationEndListener = null;
}
项目:material-components-android    文件:IndicatorViewController.java   
void addIndicator(TextView indicator, @IndicatorIndex int index) {
  if (indicatorArea == null && captionArea == null) {
    indicatorArea = new LinearLayout(context);
    indicatorArea.setOrientation(LinearLayout.HORIZONTAL);
    textInputView.addView(indicatorArea, LayoutParams.MATCH_PARENT, LayoutParams.WRAP_CONTENT);

    captionArea = new FrameLayout(context);
    indicatorArea.addView(
        captionArea,
        -1,
        new FrameLayout.LayoutParams(LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT));

    final Space spacer = new Space(context);
    final LayoutParams spacerLp = new LinearLayout.LayoutParams(0, 0, 1f);
    indicatorArea.addView(spacer, spacerLp);

    if (textInputView.getEditText() != null) {
      adjustIndicatorPadding();
    }
  }

  if (isCaptionView(index)) {
    captionArea.setVisibility(VISIBLE);
    captionArea.addView(indicator);
    captionViewsAdded++;
  } else {
    indicatorArea.addView(indicator, index);
  }
  indicatorArea.setVisibility(VISIBLE);
  indicatorsAdded++;
}
项目:AndroidSnippets    文件:ActivityEntryAdapter.java   
public ViewHolder(View itemView, ActivityEntryAdapter adapter) {
    super(itemView);
    this.adapter = adapter;
    levelSpace = (Space) itemView.findViewById(R.id.space_level);
    openedCheck = (CompoundButton) itemView.findViewById(R.id.check_opened);
    labelText = (TextView) itemView.findViewById(R.id.text_label);
}
项目:AndroidSnippets    文件:MyTreeItemAdapter.java   
public ViewHolder(View itemView, MyTreeItemAdapter adapter) {
    super(itemView);
    this.adapter = adapter;
    levelSpace = (Space) itemView.findViewById(R.id.space_level);
    openedCheck = (CompoundButton) itemView.findViewById(R.id.check_opened);
    labelText = (TextView) itemView.findViewById(R.id.text_label);
}
项目:AndroidSnippets    文件:ChoosableMyTreeItemAdapter.java   
public ViewHolder(View itemView, ChoosableMyTreeItemAdapter adapter) {
    super(itemView);
    this.adapter = adapter;
    levelSpace = (Space) itemView.findViewById(R.id.space_level);
    chosenCheck = (CompoundButton) itemView.findViewById(R.id.check_chosen);
    openedCheck = (CompoundButton) itemView.findViewById(R.id.check_opened);
    labelText = (TextView) itemView.findViewById(R.id.text_label);
}
项目:toshi-android-client    文件:ChatInputView.java   
private void showSendButton() {
    final ImageButton sendButton = (ImageButton) findViewById(R.id.send_button);
    final Space sendSpacing = (Space) findViewById(R.id.send_spacing);
    sendButton.setVisibility(View.VISIBLE);
    sendSpacing.setVisibility(View.GONE);
    ViewCompat.animate(sendButton)
            .alpha(1f)
            .setDuration(50);
}
项目:toshi-android-client    文件:ChatInputView.java   
private void hideSendButton() {
    final ImageButton sendButton = (ImageButton) findViewById(R.id.send_button);
    final Space sendSpacing = (Space) findViewById(R.id.send_spacing);
    sendButton.setVisibility(View.GONE);
    sendSpacing.setVisibility(View.VISIBLE);
    ViewCompat.animate(sendButton)
            .alpha(0f)
            .setDuration(50);
}
项目:toshi-android-client    文件:ChatInputView.java   
private void showAttachmentButton() {
    final ImageButton attachmentButton = (ImageButton) findViewById(R.id.add_attachments_button);
    final Space attachmentSpacing = (Space) findViewById(R.id.attachment_spacing);
    attachmentButton.setVisibility(View.VISIBLE);
    attachmentSpacing.setVisibility(GONE);
    ViewCompat.animate(attachmentButton)
            .alpha(1f)
            .setDuration(50);
}
项目:toshi-android-client    文件:ChatInputView.java   
private void hideAttachmentButton() {
    final ImageButton attachmentButton = (ImageButton) findViewById(R.id.add_attachments_button);
    final Space attachmentSpacing = (Space) findViewById(R.id.attachment_spacing);
    attachmentButton.setVisibility(View.GONE);
    attachmentSpacing.setVisibility(View.VISIBLE);
    ViewCompat.animate(attachmentButton)
            .alpha(0f)
            .setDuration(50);
}
项目:Qianlichuanyin    文件:DrawStatusLinearLayout.java   
private void init(Context context) {
    setOrientation(VERTICAL);
    if (INSETS_HELPER != null) {
        Space space = new Space(context);
        //ViewUtils.setDrawable(space, mStatusBarBackground);
        LayoutParams params = new LayoutParams(LayoutParams.MATCH_PARENT, LayoutParams.WRAP_CONTENT);
        params.height = ViewUtils.getStatusBarHeight(context);
        space.setLayoutParams(params);
        addView(space);
        this.mStatusBarBackground = DrawStatusLayoutCompatApi21.getDefaultStatusBarBackground(context);
        INSETS_HELPER.setupForWindowInsets(this, new ApplyInsetsListener());
    }
}
项目:SharePanel    文件:SlideHideBehaviour.java   
@Override
public boolean layoutDependsOn(CoordinatorLayout parent, CardView child, View dependency) {
    return dependency instanceof Space;
}
项目:under-the-hood    文件:ViewTemplateNoop.java   
@Override
public View constructView(ViewGroup parent, LayoutInflater inflater) {
    return new Space(parent.getContext());
}
项目:BrockmanDemo    文件:StreamViewModelHolder.java   
void bind(StreamViewModel streamViewModel) {
    slugTextView.setText(streamViewModel.streamSlug);
    displayTextView.setText(streamViewModel.streamDisplay);
    typeTextView.setText(streamViewModel.streamType.toString());
    isTranslatedTextView.setText(getTranslationText(streamViewModel.streamIsTranslated));
    VideoSize videoSize = streamViewModel.streamVideoSize;
    if (videoSize == null) {
        videoSizeTextView.setVisibility(View.GONE);
    } else {
        videoSizeTextView.setVisibility(View.VISIBLE);
        videoSizeTextView.setText(getVideoSizeText(videoSize));
    }
    String thumbnailUrl = streamViewModel.roomThumb;
    if (TextUtils.isEmpty(thumbnailUrl)) {
        thumbnailView.setVisibility(View.GONE);
    } else {
        Picasso.with(context)
                .load(thumbnailUrl)
                .resize(213, 120)
                .centerCrop()
                .into(thumbnailView);
        thumbnailView.setVisibility(View.VISIBLE);
    }
    List<Url> urls = streamViewModel.streamUrls;
    urlsLayout.removeAllViews();
    if (urls == null) {
        urlsLayout.setVisibility(View.GONE);
    } else {
        Space space = new Space(context);
        space.setMinimumHeight(30);
        urlsLayout.addView(space);
        LAYOUT_PARAMS.setMargins(0, 10, 0, 0);
        for (Url url : urls) {
            addUrlViews(LAYOUT_PARAMS, url);
        }
        urlsLayout.setVisibility(View.VISIBLE);
    }
    String roomLink = context.getString(R.string.room_link, streamViewModel.roomLink);
    roomLinkTextView.setMovementMethod(LinkMovementMethod.getInstance());
    roomLinkTextView.setText(roomLink);
    Linkify.addLinks(roomLinkTextView, Linkify.WEB_URLS);
}