Я пытаюсь добавить views
по вертикали в LinearLayout
, как на картинке ниже:
![enter image description here](https://i.stack.imgur.com/u0TP0.png)
код ниже дает мне что-то вродеэто:
![enter image description here](https://i.stack.imgur.com/gyPaw.jpg)
private void configure(View view) {
LinearLayout palletContainer = view.findViewById(R.id.palette_container);
fillPalletColors(mPalette, palletContainer);
}
private void fillPalletColors(List<Integer> colors, LinearLayout paletteContainer) {
if (getActivity() != null && isAdded()) {
LayoutInflater inflater = getActivity().getLayoutInflater();
for (int color : colors) {
View palletColor = inflater.inflate(R.layout.suggested_color_item_center, paletteContainer, false);
palletColor.setBackgroundColor(color);
paletteContainer.addView(palletColor);
}
}
}
XML :
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:gravity="center_vertical"
android:orientation="vertical">
<LinearLayout
android:id="@+id/palette_container"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:gravity="center"
android:orientation="vertical" />
</LinearLayout>