如何在网格视图中设置颜色大小并将其形状更改为圆形

How to set size of colour in grid view and change it's shape to round

package com.example.dhavalpatel.atira;

import android.content.Intent;
import android.graphics.Color;
import android.support.v7.app.ActionBarActivity;
import android.os.Bundle;
import android.view.Menu;
import android.view.MenuItem;
import android.view.View;
import android.widget.AdapterView;
import android.widget.ArrayAdapter;
import android.widget.Button;
import android.widget.GridLayout;
import android.widget.GridView;
import android.widget.TableLayout;
import android.widget.Toast;


public class second extends ActionBarActivity { 
     GridView gv;  

    String[] value1=value1=new String[]{"0","1","0","1","0"};
    String imc_met;

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

        gv=(GridView)findViewById(R.id.gridView);

            public View getView(int position, View convertView, ViewGroup parent) {


                View view = super.getView(position, convertView, parent);
                String value = getItem(position);
                if (value.equals("0")) {
                  view.setVisibility(View.INVISIBLE);



                } 

          else {


                    ((TextView) view).setTextColor(Color.BLUE);
                    ((TextView) view).setTextSize((float) 1);
                    view.setBackgroundColor(Color.RED);

               }
                return view;
            }

        };

        gv.setAdapter(ad);
   }

注意:我想在网格视图中设置单元格的高度和宽度。我用了grid view.setcolumnwidth,view.setHeight,view.setWidth,还有很多,都没有效果。我也想把cell的shape定义为圆形,试了一些方法和函数都没有用。

按照说明使您的物品呈正方形 here

@Override
public void onMeasure(int widthMeasureSpec, int heightMeasureSpec) {
    super.onMeasure(widthMeasureSpec, widthMeasureSpec);
}

并使用 Drawable 设置项目的背景

<shape 
    xmlns:android="http://schemas.android.com/apk/res/android"
    android:shape="oval" >
    <solid android:color="#79bfea" />
</shape>