GridView setGravity - top ranked examples from Open Source projects

These code examples were ranked by Codota’s semantic indexing as the best open source examples for GridView setGravity method.

This code example shows how to use the following methods: setOverScrollMode, setColumnWidth, setGravity, setNumColumns, setVerticalSpacing
	public GridViewFragment() { 
		super(); 
	} 
 
	public void setUpGridView(GridView gv) {
		gv.setColumnWidth(200);
		gv.setGravity(Gravity.CENTER);
		gv.setOverScrollMode(View.OVER_SCROLL_ALWAYS);
		gv.setNumColumns(GridView.AUTO_FIT);
		gv.setVerticalSpacing(15);
	} 
	 
	@Override 
	public void onCreate(Bundle savedInstanceState) {
		super.onCreate(savedInstanceState);
	} 
 
	@Override 
	public View onCreateView(LayoutInflater inflater, ViewGroup container,
			Bundle savedInstanceState) {
Full Snippet Info
6
CodeRank
Stop searching for code, let great code find you!  Add Codota to your java IDE
This code example shows how to use the following methods: setGravity, setHorizontalSpacing, setNumColumns, setStretchMode, setVerticalSpacing
		this.mResources = context.getResources();
		init(); 
	} 
	 
	private void init() { 
		mGridView = new GridView(mContext);
		mGridView.setNumColumns(4);
		mGridView.setHorizontalSpacing(10);
		mGridView.setVerticalSpacing(10);
		mGridView.setStretchMode(GridView.STRETCH_COLUMN_WIDTH);
		mGridView.setGravity(Gravity.CENTER);
		mGridView.setOnItemClickListener(this);
		setAdapterData(menu_name, menu_image);
	} 
 
	private void setAdapterData(String[] menus_name,String[] menus_image) {
		/** 数据源  **/ 
		ArrayList<HashMap<String, Object>> data = new ArrayList<HashMap<String, Object>>();
		/** 添加数据 **/ 
		 for (int i = 0; i < menus_name.length; i++) {            
Full Snippet Info
6
CodeRank
Stop searching for code, let great code find you!  Add Codota to your java IDE
This code example shows how to use the following methods: setPadding, setVerticalScrollBarEnabled, setAdapter, setGravity, setNumColumns
		 
		Vector <DataIndicator> currentRow = rows.get(position);
		 
		GridView gridView;
        if (convertView == null) {
        	gridView = new GridView(mContext);
             
            gridView.setVerticalScrollBarEnabled(false);          
 
            gridView.setNumColumns(currentRow.size());
            gridView.setPadding(1,1,1,1);
            //gridView.setLayoutParams(new LayoutParams (LayoutParams.FILL_PARENT, 40)); 
            gridView.setGravity(Gravity.CENTER);
            gridView.setStretchMode(GridView.STRETCH_COLUMN_WIDTH);
 
        } else { 
        	gridView = (GridView) convertView;
        } 
 
        DataListItemAdapter itemAdapter = new DataListItemAdapter(mContext, currentRow, false);

6
CodeRank
Stop searching for code, let great code find you!  Add Codota to your java IDE
This code example shows how to use the following methods: setLayoutParams, setPadding, setGravity, setHorizontalSpacing, setNumColumns
This code example shows how to use the following methods: setLayoutParams, setPadding, setSelector, setGravity, setHorizontalSpacing
		super(context);
 
		mLayout = new LinearLayout(context);
		mLayout.setOrientation(LinearLayout.VERTICAL);
 
		gridView = new GridView(context);
		gridView.setLayoutParams(new LayoutParams(LayoutParams.MATCH_PARENT,
				LayoutParams.WRAP_CONTENT));
		gridView.setSelector(new ColorDrawable(Color.TRANSPARENT));// 选中的时候为透明色
		gridView.setNumColumns(bodyAdapter.resID.length);
		gridView.setStretchMode(GridView.STRETCH_COLUMN_WIDTH);
		gridView.setVerticalSpacing(0);
		gridView.setHorizontalSpacing(0);
		gridView.setPadding(0, 0, 0, 0);
		gridView.setGravity(Gravity.CENTER);
		gridView.setOnItemClickListener(bodyClick);
		//gridView.setBackgroundResource(R.drawable.button); 
		 
		mLayout.addView(gridView);
		// 设置默认项 
		this.setContentView(mLayout);
Full Snippet Info
4
CodeRank
Stop searching for code, let great code find you!  Add Codota to your java IDE

Related GridView setGravity Questions & Answers:

setGravity Method Overview
Set the gravity for this grid.
See Code Examples for other Android GridView Methods: