2
私はこれをflexbox layoutを使用しています。私は行動をとどめている。動的に追加されたアイテムがFlexboxLayout
に収まらない場合は、アイテムを次の行に表示します。フレキシボックスがコンテンツを縮小し、アンドロイド:フレックスボックスの包装内容なし
private void generateCategories(UserCategoryListResponse userCategoryListResponse) {
for (UserCategoryListResponse.Datum data : userCategoryListResponse.getData()) {
mFlexboxLayout.addView(getCategoryRadioButton(data));
}
}
private RadioButton getCategoryRadioButton(UserCategoryListResponse.Datum data) {
RadioButton radioButton = new RadioButton(this);
radioButton.setId(Integer.parseInt(data.getCategoryId()));
radioButton.setBackgroundResource(R.drawable.selector_choose_category);
radioButton.setButtonDrawable(null);
radioButton.setPadding(DisplayUtils.pxToDp(this, 16), DisplayUtils.pxToDp(this, 16), DisplayUtils.pxToDp(this, 16), DisplayUtils.pxToDp(this, 16));
radioButton.setText(data.getCategoryName());
radioButton.setTypeface(radioButton.getTypeface(), Typeface.BOLD);
radioButton.setEnabled(data.getIsFree().equals("1"));
radioButton.setOnCheckedChangeListener(this);
return radioButton;
}
しかし、実際に起こって何です:
<com.google.android.flexbox.FlexboxLayout
android:id="@+id/fbl_choose_category_upload"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_marginTop="@dimen/margin_16"
android:paddingLeft="@dimen/padding_16"
android:paddingRight="@dimen/padding_16"
app:alignContent="space_between"
app:alignItems="flex_start"
app:flexDirection="row"
app:flexWrap="wrap"
app:justifyContent="space_between">
</com.google.android.flexbox.FlexboxLayout>
私のJavaコード:
Flexbox Version: 0.2.2
誰でも私にこれを手伝うことができます。
はいこれは私の代替ソリューションです。 –