本文整理汇总了Java中android.support.v4.widget.Space类的典型用法代码示例。如果您正苦于以下问题:Java Space类的具体用法?Java Space怎么用?Java Space使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
Space类属于android.support.v4.widget包,在下文中一共展示了Space类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: setCompoundDrawables
import android.support.v4.widget.Space; //导入依赖的package包/类
/**
* 设置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;
}
示例2: leftAndRightDrawable
import android.support.v4.widget.Space; //导入依赖的package包/类
/**
* 设置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;
}
示例3: addIndicator
import android.support.v4.widget.Space; //导入依赖的package包/类
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++;
}
示例4: onCreateViewHolder
import android.support.v4.widget.Space; //导入依赖的package包/类
@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;
}
示例5: addIndicator
import android.support.v4.widget.Space; //导入依赖的package包/类
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++;
}
示例6: addBuffersToView
import android.support.v4.widget.Space; //导入依赖的package包/类
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);
}
}
示例7: findViews
import android.support.v4.widget.Space; //导入依赖的package包/类
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);
}
示例8: init
import android.support.v4.widget.Space; //导入依赖的package包/类
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("");
}
示例9: addIndicator
import android.support.v4.widget.Space; //导入依赖的package包/类
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++;
}
示例10: init
import android.support.v4.widget.Space; //导入依赖的package包/类
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);
}
示例11: GoodJob
import android.support.v4.widget.Space; //导入依赖的package包/类
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;
}
示例12: addIndicator
import android.support.v4.widget.Space; //导入依赖的package包/类
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++;
}
开发者ID:material-components,项目名称:material-components-android,代码行数:32,代码来源:IndicatorViewController.java
示例13: ViewHolder
import android.support.v4.widget.Space; //导入依赖的package包/类
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);
}
示例14: ViewHolder
import android.support.v4.widget.Space; //导入依赖的package包/类
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);
}
示例15: ViewHolder
import android.support.v4.widget.Space; //导入依赖的package包/类
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);
}