Q:

Android: populating Linear Layout programmatically, It gets extra space

I'm trying to populate a LinearLayout horizontally with some ImageViews programmatically.  In horizontal directon, everything works very well, but it reserves extra space vertically what I don't want. 
Here is the xml:
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical"
android:paddingBottom="@dimen/activity_vertical_margin"
android:paddingLeft="@dimen/activity_horizontal_margin"
android:paddingRight="@dimen/activity_horizontal_margin"
android:paddingTop="@dimen/activity_vertical_margin"
tools:context="es.uam.dadm.jacopo_grassi_connecta4.Settings" >

<TextView
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:text="@string/your_color" />

<LinearLayout
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    android:orientation="horizontal"
    android:id="@+id/your_color_container" >

</LinearLayout>

<TextView
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:text="@string/adv_color" />

<LinearLayout
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    android:orientation="horizontal"
    android:id="@+id/adv_color_container" >

</LinearLayout>

<RelativeLayout
    android:layout_width="match_parent"
    android:layout_height="wrap_content" >

    <TextView
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:text="@string/sounds" />

    <Switch
        android:id="@+id/sounds_switch"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_alignParentRight="true" />
</RelativeLayout>

and here's the java code:
private PlayerDataSource playersdb;
private Player player;

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_settings);

    Bundle extras = getIntent().getExtras();
    playersdb = new PlayerDataSource(this);
    player = playersdb.getPlayer(extras.getString(Utils. PARAM_PLAYER_ID));

    buildColors();

    Switch sounds = (Switch)findViewById(R.id.sounds_switch);
    sounds.setOnCheckedChangeListener(this);
    sounds.setChecked(player.getSounds() == 0 ?  false : true);
}

@Override
public void onClick(View v) {
    Integer tag = (Integer) v.getTag(R.id. TAG_ADV);
    if(tag == null){        //your color
        tag = (Integer) v.getTag(R.id. TAG_YOU);
        player.setColor(tag);
    }else{                  //adv color
        player.setColorAdv(tag);
    }
    playersdb.updatePlayer(player);
    buildColors();
}

@Override
public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) {
    if(isChecked){
        player.setSounds(1);
    }else{
        player.setSounds(0);
    }
    playersdb.updatePlayer(player);
}

private void buildColors(){
    LinearLayout parent = (LinearLayout)findViewById(R.id.your_color_container);
    parent.removeAllViewsInLayout();

    for (int i = 0; i < 5; ++i) {
        LinearLayout. LayoutParams params = new LayoutParams(LayoutParams. WRAP_CONTENT, LayoutParams. WRAP_CONTENT);
        params.weight = 0.2f;
        ImageView v = new ImageView(this);
        Integer drawable = null;
        switch (i){
        case 0:
            drawable = R.drawable.red_piece;
            break;
        case 1:
            drawable = R.drawable.yellow_piece;
            break;
        case 2:
            drawable = R.drawable.green_piece;
            break;
        case 3:
            drawable = R.drawable.purple_piece;
            break;
        case 4:
            drawable = R.drawable.azure_piece;
            break;
        }
        v.setLayoutParams(params);
        v.setImageResource(drawable);
        v.setTag(R.id. TAG_YOU, drawable);
        v.setOnClickListener(this);

        if (drawable.equals(player.getColor())) {
            v.setBackgroundColor(getResources().getColor(R.color.azul));
        }

        parent.addView(v);
    }

    parent = (LinearLayout)findViewById(R.id.adv_color_container);
    parent.removeAllViewsInLayout();

    for (int i = 0; i < 5; ++i) {
        LinearLayout. LayoutParams params = new LayoutParams(LayoutParams. WRAP_CONTENT, LayoutParams. WRAP_CONTENT);
        params.weight = 0.2f;
        ImageView v = new ImageView(this);
        Integer drawable = null;
        switch (i){
        case 0:
            drawable = R.drawable.red_piece;
            break;
        case 1:
            drawable = R.drawable.yellow_piece;
            break;
        case 2:
            drawable = R.drawable.green_piece;
            break;
        case 3:
            drawable = R.drawable.purple_piece;
            break;
        case 4:
            drawable = R.drawable.azure_piece;
            break;
        }
        v.setLayoutParams(params);
        v.setImageResource(drawable);
        v.setTag(R.id. TAG_ADV, drawable);
        v.setOnClickListener(this);

        if (drawable.equals(player.getColorAdv())) {
            v.setBackgroundColor(getResources().getColor(R.color.azul));
        }

        parent.addView(v);
    }
}

and that's the result:

Obviously, the images are perfect squares. 
What am I doing wrong? 

A:

Solved thanks to @Terence 
Added 
v.setAdjustViewBounds = true;

