本文整理汇总了Java中com.google.android.flexbox.FlexboxLayout类的典型用法代码示例。如果您正苦于以下问题:Java FlexboxLayout类的具体用法?Java FlexboxLayout怎么用?Java FlexboxLayout使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
FlexboxLayout类属于com.google.android.flexbox包,在下文中一共展示了FlexboxLayout类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: fromFlexView
import com.google.android.flexbox.FlexboxLayout; //导入依赖的package包/类
public static FlexItem fromFlexView(View view, int index) {
FlexboxLayout.LayoutParams lp = (FlexboxLayout.LayoutParams) view.getLayoutParams();
FlexItem flexItem = new FlexItem();
flexItem.index = index;
flexItem.order = lp.order;
flexItem.flexGrow = lp.flexGrow;
flexItem.flexShrink = lp.flexShrink;
flexItem.alignSelf = lp.alignSelf;
flexItem.flexBasisPercent = lp.flexBasisPercent;
flexItem.width = Util.pixelToDp(view.getContext(), lp.width);
flexItem.height = Util.pixelToDp(view.getContext(), lp.height);
flexItem.topMargin = lp.topMargin;
flexItem.startMargin = MarginLayoutParamsCompat.getMarginStart(lp);
flexItem.endMargin = MarginLayoutParamsCompat.getMarginEnd(lp);
flexItem.bottomMargin = lp.bottomMargin;
flexItem.paddingTop = view.getPaddingTop();
flexItem.paddingStart = ViewCompat.getPaddingStart(view);
flexItem.paddingEnd = ViewCompat.getPaddingEnd(view);
flexItem.paddingBottom = view.getPaddingBottom();
return flexItem;
}
示例2: addItemTrainCategories
import com.google.android.flexbox.FlexboxLayout; //导入依赖的package包/类
public ItemBuilder addItemTrainCategories(Context context) {
view = inflater.inflate(R.layout.item_element_categories_checkboxes, parent, false);
TextView tv = (TextView) view.findViewById(R.id.tv_title);
TextView tv2 = (TextView) view.findViewById(R.id.tv_subtitle);
FlexboxLayout fblCategories = (FlexboxLayout) view.findViewById(R.id.fbl_categories);
tv.setText("Categorie di treni incluse nella ricerca");
tv2.setText(SettingsPreferences.getCategoriesAsString(context, " / "));
for (ENUM_CATEGORIES cat : ENUM_CATEGORIES.values()) {
CheckBox cbCat = new CheckBox(context);
FlexboxLayout.LayoutParams params = new FlexboxLayout.LayoutParams(ViewGroup.LayoutParams.WRAP_CONTENT, ViewGroup.LayoutParams.WRAP_CONTENT);
params.flexBasisPercent = 0.5f;
cbCat.setLayoutParams(params);
cbCat.setText(cat.getAlias());
cbCat.setChecked(SettingsPreferences.isCategoryEnabled(context, cat));
cbCat.setOnCheckedChangeListener((buttonView, isChecked) -> {
if (isChecked || (!isChecked && SettingsPreferences.isPossibleToDisableCheckbox(context))) {
SettingsPreferences.setCategory(context, cat.name(), isChecked);
tv2.setText(SettingsPreferences.getCategoriesAsString(context, " / "));
} else {
cbCat.setChecked(true);
}
});
fblCategories.addView(cbCat);
}
return this;
}
示例3: instantiateItem
import com.google.android.flexbox.FlexboxLayout; //导入依赖的package包/类
@Override
public Object instantiateItem(ViewGroup collection, int position) {
LayoutInflater inflater = LayoutInflater.from(getContext());
ViewGroup layout = (ViewGroup) inflater.inflate(R.layout.view_filters_sorters, collection, false);
FlexboxLayout fbl = (FlexboxLayout) layout.findViewById(R.id.fbl);
// LinearLayout ll_scroll = (LinearLayout) layout.findViewById(R.id.ll_scroll);
// FrameLayout.LayoutParams lp = new FrameLayout.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, (int) (metrics.heightPixels-(104*metrics.density)));
// ll_scroll.setLayoutParams(lp);
switch (position) {
case 0:
inflateLayoutWithFilters("genre", fbl);
break;
case 1:
inflateLayoutWithFilters("rating", fbl);
break;
case 2:
inflateLayoutWithFilters("year", fbl);
break;
case 3:
inflateLayoutWithFilters("quality", fbl);
break;
}
collection.addView(layout);
return layout;
}
示例4: justContent
import com.google.android.flexbox.FlexboxLayout; //导入依赖的package包/类
@FlexboxLayout.JustifyContent
private static int justContent(java.lang.String content) {
switch (content) {
case "flex-start":
return FlexboxLayout.JUSTIFY_CONTENT_FLEX_START;
case "flex-end":
return FlexboxLayout.JUSTIFY_CONTENT_FLEX_END;
case "center":
return FlexboxLayout.JUSTIFY_CONTENT_CENTER;
case "space-between":
return FlexboxLayout.JUSTIFY_CONTENT_SPACE_BETWEEN;
case "space-around":
return FlexboxLayout.JUSTIFY_CONTENT_SPACE_AROUND;
default:
return FlexboxLayout.JUSTIFY_CONTENT_FLEX_START;
}
}
示例5: byClass
import com.google.android.flexbox.FlexboxLayout; //导入依赖的package包/类
public static StyleHandler byClass(@NonNull Class<? extends View> clazz) {
if (TextView.class.isAssignableFrom(clazz)) {
return sText;
} else if (ImageView.class.isAssignableFrom(clazz)) {
return sImage;
} else if (clazz.equals(HNDivLayout.class)) {
return sDiv;
} else if (clazz.equals(FlexboxLayout.class)) {
return sFlex;
} else if (clazz.equals(WebView.class)) {
return sWebview;
} else {
return null;
}
}
示例6: createLayoutParams
import com.google.android.flexbox.FlexboxLayout; //导入依赖的package包/类
public static ViewGroup.LayoutParams createLayoutParams(View parent, LayoutParamsCreator
creator) {
if (parent instanceof HNDivLayout) {
return creator.toHNDivLayoutParams();
} else if (parent instanceof HNRootView) {
return creator.toMarginLayoutParams();
} else if (parent instanceof FlexboxLayout) {
return creator.toFlexLayoutParams();
} else {
throw new IllegalArgumentException("can't create related layoutParams, unknown " +
"view type " + parent.toString());
}
}
示例7: PhotoPostVH
import com.google.android.flexbox.FlexboxLayout; //导入依赖的package包/类
public PhotoPostVH(View itemView) {
super(itemView);
context = itemView.getContext();
avatarView = (SimpleDraweeView) itemView.findViewById(R.id.post_avatar);
nameView = (TextView) itemView.findViewById(R.id.post_name);
itemView.findViewById(R.id.post_header).setOnClickListener(this);
timeView = (TextView) itemView.findViewById(R.id.post_time);
sourceView = (TextView) itemView.findViewById(R.id.post_source);
sourceView.setOnClickListener(this);
contentLayout = (FlexboxLayout) itemView.findViewById(R.id.post_content);
trailLayout = (LinearLayout) itemView.findViewById(R.id.post_trail);
noteCountView = (TextView) itemView.findViewById(R.id.note_count);
reblogView = (ImageView) itemView.findViewById(R.id.post_reblog);
reblogView.setOnClickListener(this);
likeView = (ImageView) itemView.findViewById(R.id.post_like);
likeView.setOnClickListener(this);
dividerWidth = (int) Utils.dp2Pixels(context, 4);
deleteStub = (ViewStub) itemView.findViewById(R.id.stub_delete_forever);
isSimpleMode = DataManager.getInstance().isSimpleMode();
if (isSimpleMode) {
trailLayout.setVisibility(View.GONE);
}
}
示例8: onCreateView
import com.google.android.flexbox.FlexboxLayout; //导入依赖的package包/类
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container,
Bundle savedInstanceState) {
// Check if we've retained the Fragment or are creating it for the first time.
if (retainedLayout == null) {
// When creating for the first time we need to add the default tags for the default image.
LinearLayout resultView = (LinearLayout)inflater.inflate(R.layout.recognition_result_view, container, false);
FlexboxLayout imageTagContainer = (FlexboxLayout)inflater.inflate(R.layout.tag_box, null, false);
imageTagContainer.addView(RecognitionResultBuilder.constructImageTag(inflater, "Blue Sky", "85%"));
imageTagContainer.addView((RecognitionResultBuilder.constructImageTag(inflater, "Landscape", "60%")));
resultView.addView(imageTagContainer);
return resultView;
} else {
return retainedLayout;
}
}
示例9: onCreateView
import com.google.android.flexbox.FlexboxLayout; //导入依赖的package包/类
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container,
Bundle savedInstanceState) {
// Check if we've retained the Fragment or are creating it for the first time.
if (retainedLayout == null) {
// When creating for the first time we need to add the default tags for the default image.
LinearLayout resultView = (LinearLayout)inflater.inflate(R.layout.recognition_result_view, container, false);
FlexboxLayout imageTagContainer = (FlexboxLayout)inflater.inflate(R.layout.tag_box, null, false);
// imageTagContainer.addView(RecognitionResultBuilder.constructImageTag(inflater, "Blue Sky", "85%"));
// imageTagContainer.addView((RecognitionResultBuilder.constructImageTag(inflater, "Landscape", "60%")));
resultView.addView(imageTagContainer);
return resultView;
}
else {
return retainedLayout;
}
}
示例10: loadMinuteCircles
import com.google.android.flexbox.FlexboxLayout; //导入依赖的package包/类
private void loadMinuteCircles() {
minuteCircles = new ArrayList<>();
LinearLayout.LayoutParams lp = new LinearLayout.LayoutParams(
ViewGroup.LayoutParams.WRAP_CONTENT,
ViewGroup.LayoutParams.WRAP_CONTENT);
lp.setMargins(0, 10, 0, 10);
for (Integer minutes : schedules.keySet()) {
// inflate view
View minuteCircleView = inflater.inflate(R.layout.item_schedule_minutes, circleContainer, false);
minuteCircleView.setLayoutParams(lp);
// update minutes text
TextView minutesLabel = minuteCircleView.findViewById(R.id.minutesLabel);
minutesLabel.setText(minutes + "");
// load descriptions
FlexboxLayout descriptionContainer = minuteCircleView.findViewById(R.id.descriptionContainer);
loadScheduleDescriptions(descriptionContainer, minutes);
// add to arraylist and to layout
minuteCircles.add(minuteCircleView);
circleContainer.addView(minuteCircleView);
}
}
示例11: loadScheduleDescriptions
import com.google.android.flexbox.FlexboxLayout; //导入依赖的package包/类
private void loadScheduleDescriptions(FlexboxLayout descriptionContainer, int minutes) {
int index = 0;
for (ScheduleType scheduleType : schedules.get(minutes)) {
View descriptionView = inflater.inflate(R.layout.item_schedule_description, descriptionContainer, false);
// set up onclick listener
LinearLayout scheduleLayout = descriptionView.findViewById(R.id.scheduleLayout);
scheduleLayout.setOnClickListener(view -> {
loadScheduleDetails(scheduleType);
});
// update textviews
TextView monthsLabel = descriptionView.findViewById(R.id.bigLengthLabel);
TextView weeksLabel = descriptionView.findViewById(R.id.smallLengthLabel);
TextView repsLabel = descriptionView.findViewById(R.id.repsLabel);
monthsLabel.setText(scheduleType.getCourseLength());
weeksLabel.setText(scheduleType.getCourseLengthSmall());
repsLabel.setText(scheduleType.getRepsAsString());
// if it's the last one, don't show the "or"
if (++index == schedules.get(minutes).size()) {
TextView orLabel = descriptionView.findViewById(R.id.orLabel);
orLabel.setVisibility(View.GONE);
}
// add view to container
descriptionContainer.addView(descriptionView);
}
}
示例12: createView
import com.google.android.flexbox.FlexboxLayout; //导入依赖的package包/类
@Override
public View createView(Context context, EventListFragment.OnLinkClickListener listener) {
if (mPublicEventEntity == null) {
return newTextView(context, "data empty", false, null);
}
FlexboxLayout flexboxLayout = newFlexboxLayout(context);
TextView actionTextView = newTextView(context, "A private repository", true, null);
flexboxLayout.addView(actionTextView);
TextView userTextView = newTextView(context, getRepo().getFullName(), true,
newOnLinkClickClickableSpan(listener, getRepo().getFullName(), getRepo().getHtmlUrl(), getRepo()));
flexboxLayout.addView(userTextView);
TextView toTextView = newTextView(context, "is open sourced", false, null);
flexboxLayout.addView(toTextView);
return flexboxLayout;
}
示例13: createView
import com.google.android.flexbox.FlexboxLayout; //导入依赖的package包/类
@Override
public View createView(Context context, EventListFragment.OnLinkClickListener listener) {
if(mPushEntity == null){
return newTextView(context, "data empty", false, null);
}
FlexboxLayout flexboxLayout = newFlexboxLayout(context);
TextView actionTextView = newTextView(context, "pushed", true, null);
flexboxLayout.addView(actionTextView);
GithubRepoEntity githubRepoEntity = new GithubRepoEntity(getRepo().getName());
TextView pullRequestTextView = newTextView(context, githubRepoEntity.getFullName(), false, newOnLinkClickClickableSpan(listener, githubRepoEntity.getFullName(), githubRepoEntity.getHtmlUrl(),githubRepoEntity));
flexboxLayout.addView(pullRequestTextView);
return flexboxLayout;
}
示例14: createView
import com.google.android.flexbox.FlexboxLayout; //导入依赖的package包/类
@Override
public View createView(Context context, EventListFragment.OnLinkClickListener listener) {
if (mMembershipEntity == null) {
return newTextView(context, "data empty", false, null);
}
FlexboxLayout flexboxLayout = newFlexboxLayout(context);
TextView actionTextView = newTextView(context, mMembershipEntity.getAction(), true, null);
flexboxLayout.addView(actionTextView);
TextView userTextView = newTextView(context, mMembershipEntity.getMember().getLogin(), true,
newOnLinkClickClickableSpan(listener, mMembershipEntity.getMember().getLogin(), mMembershipEntity.getMember().getHtmlUrl(), getRepo()));
flexboxLayout.addView(userTextView);
TextView toTextView = newTextView(context, "to", true, null);
flexboxLayout.addView(toTextView);
TextView repoTextView = newTextView(context, getRepo().getName(), false,
newOnLinkClickClickableSpan(listener, getRepo().getName(), getRepo().getHtmlUrl(), getRepo()));
flexboxLayout.addView(repoTextView);
return flexboxLayout;
}
示例15: createView
import com.google.android.flexbox.FlexboxLayout; //导入依赖的package包/类
@Override
public View createView(Context context, EventListFragment.OnLinkClickListener listener) {
if (mMemberEventEntity == null) {
return newTextView(context, "data empty", false, null);
}
FlexboxLayout flexboxLayout = newFlexboxLayout(context);
TextView actionTextView = newTextView(context, mMemberEventEntity.getAction(), true, null);
flexboxLayout.addView(actionTextView);
TextView userTextView = newTextView(context, mMemberEventEntity.getUser().getLogin(), true,
newOnLinkClickClickableSpan(listener, mMemberEventEntity.getUser().getLogin(), mMemberEventEntity.getUser().getHtmlUrl(), getRepo()));
flexboxLayout.addView(userTextView);
TextView toTextView = newTextView(context, "to", true, null);
flexboxLayout.addView(toTextView);
TextView repoTextView = newTextView(context, getRepo().getName(), false,
newOnLinkClickClickableSpan(listener, getRepo().getName(), getRepo().getHtmlUrl(), getRepo()));
flexboxLayout.addView(repoTextView);
return flexboxLayout;
}