Java Code Examples for android.widget.GridView#setBackgroundColor()
The following examples show how to use
android.widget.GridView#setBackgroundColor() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: EmoGridView.java From sctalk with Apache License 2.0 | 6 votes |
private GridView getViewPagerItem(final int index) { GridView gridView = new GridView(_context); gridView.setLayoutParams(new LayoutParams(LayoutParams.MATCH_PARENT, LayoutParams.WRAP_CONTENT)); gridView.setNumColumns(7); gridView.setVerticalScrollBarEnabled(false); gridView.setHorizontalScrollBarEnabled(false); gridView.setPadding(8, 8, 8, 0); gridView.setVerticalSpacing(CommonUtil.getElementSzie(_context) / 2 + CommonUtil.getElementSzie(_context) / 3); // gridView.setVerticalSpacing(30); gridView.setBackgroundColor(Color.TRANSPARENT); gridView.setAdapter(new EmoGridViewAdapter(_context, getGridViewData(index))); gridView.setOnItemClickListener(new OnItemClickListener() { @Override public void onItemClick(AdapterView<?> parent, View view, int position, long id) { int start = index * (SysConstant.pageSize - 1); onEmoGridViewItemClick.onItemClick(position + start, index); } }); return gridView; }
Example 2
Source File: MainLayout.java From emerald with GNU General Public License v3.0 | 5 votes |
private static void initAppsGrid(GridView grid, SharedPreferences options) { grid.setBackgroundColor(options.getInt(Keys.APPS_WINDOW_BACKGROUND, 0)); if (options.getBoolean(Keys.STACK_FROM_BOTTOM, false)) { grid.setStackFromBottom(true); } if (options.getBoolean(Keys.TILE, true)) { grid.setNumColumns(GridView.AUTO_FIT); } if (options.getBoolean(Keys.SCROLLBAR, false)) { setFastScroll(grid); } }
Example 3
Source File: MyColorPicker.java From Ruisi with Apache License 2.0 | 5 votes |
private void init() { String[] colors = mContext.getResources().getStringArray(R.array.color_list); for (int i = 0; i < colors.length; i++) { if (colorDatas == null) { colorDatas = new String[colors.length][2]; } colorDatas[i][0] = colors[i].split(",")[0]; colorDatas[i][1] = colors[i].split(",")[1]; } gridView = new GridView(mContext); gridView.setLayoutParams(new ViewGroup.LayoutParams(ViewGroup.LayoutParams.WRAP_CONTENT, ViewGroup.LayoutParams.WRAP_CONTENT)); gridView.setBackgroundColor(ContextCompat.getColor(mContext, R.color.white)); gridView.setNumColumns(8); gridView.setPadding(DimenUtils.dip2px(mContext, 8), DimenUtils.dip2px(mContext, 12), DimenUtils.dip2px(mContext, 8), DimenUtils.dip2px(mContext, 12)); gridView.setGravity(Gravity.CENTER); gridView.setHorizontalSpacing(DimenUtils.dip2px(mContext, 4)); gridView.setVerticalSpacing(DimenUtils.dip2px(mContext, 12)); gridView.setOnItemClickListener(this); setWidth(ViewGroup.LayoutParams.WRAP_CONTENT); setHeight(ViewGroup.LayoutParams.WRAP_CONTENT); setBackgroundDrawable(ContextCompat.getDrawable(mContext, R.drawable.rec_solid_primary_bg)); setFocusable(true); setContentView(gridView); adapter = new MyAdapter(); gridView.setAdapter(adapter); }
Example 4
Source File: ChatActivity.java From weixin with Apache License 2.0 | 4 votes |
/** * 设置笑脸被点击后的表情数据 */ private void setSmilingfaceData() { mV_myScrollView = new MyScrollView(this); mList_emoji = FaceConversionUtil.getInstace().emojiLists; // 添加表情页 mList_emojiAdapter = new ArrayList<EmojiAdapter>(); mV_myScrollView.removeAllViews(); for (int i = 0; i < mList_emoji.size(); i++) { // GridView的一些特殊属性: // // 1.android:numColumns=”auto_fit” //GridView的列数设置为自动 // 2.android:columnWidth=”90dp " //每列的宽度,也就是Item的宽度 // 3.android:stretchMode=”columnWidth"//缩放与列宽大小同步 // 4.android:verticalSpacing=”10dp” //两行之间的边距 // 5.android:horizontalSpacing=”10dp” //两列之间的边距 // 6.android:cacheColorHint="#00000000" //去除拖动时默认的黑色背景 // 7.android:listSelector="#00000000" //去除选中时的黄色底色 // 8.android:scrollbars="none" //隐藏GridView的滚动条 // 9.android:fadeScrollbars="true" //设置为true就可以实现滚动条的自动隐藏和显示 // 10.android:fastScrollEnabled="true" //GridView出现快速滚动的按钮(至少滚动4页才会显示) // 11.android:fadingEdge="none" //GridView衰落(褪去)边缘颜色为空,缺省值是vertical。(可以理解为上下边缘的提示色) // 12.android:fadingEdgeLength="10dip" //定义的衰落(褪去)边缘的长度 // 13.android:stackFromBottom="true" //设置为true时,你做好的列表就会显示你列表的最下面 // 14.android:transcriptMode="alwaysScroll" //当你动态添加数据时,列表将自动往下滚动最新的条目可以自动滚动到可视范围内 // 15.android:drawSelectorOnTop="false" //点击某条记录不放,颜色会在记录的后面成为背景色,内容的文字可见(缺省为false) // GridView view = new GridView(this); EmojiAdapter adapter = new EmojiAdapter(this, mList_emoji.get(i)); view.setAdapter(adapter); mList_emojiAdapter.add(adapter); view.setOnItemClickListener(this); view.setNumColumns(7); view.setBackgroundColor(Color.TRANSPARENT); // view.setHorizontalSpacing(1); //两列之间的边距 // view.setVerticalSpacing(10);//两行之间的边距 view.setStretchMode(GridView.STRETCH_COLUMN_WIDTH);//缩放与列宽大小同步 view.setCacheColorHint(0);//去除拖动时默认的黑色背景 // view.setPadding(5, 5, 5, 5); view.setSelector(new ColorDrawable(Color.TRANSPARENT)); LayoutParams params = new LayoutParams(LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT); view.setLayoutParams(params); view.setGravity(Gravity.CENTER); mV_myScrollView.addView(view); } mLl_chat_smilingface_body.removeAllViews(); mLl_chat_smilingface_body.addView(mV_myScrollView);//将MyScrollView添加到内容显示区 RadioGroup.LayoutParams params_rb = new RadioGroup.LayoutParams(DensityUtil.dip2px(this, 8), DensityUtil.dip2px(this, 8)); int marginValue = DensityUtil.dip2px(this, 3); params_rb.setMargins(marginValue, 0, marginValue, 0); for (int i = 0; i < mV_myScrollView.getChildCount(); i++) { RadioButton rbtn = new RadioButton(this); rbtn.setButtonDrawable(R.drawable.cgt_selector_chat_radiobtn_bg); rbtn.setId(i); mRg_chat_smilingface_tab.addView(rbtn, params_rb); if (i == 0) { rbtn.setChecked(true); } } /** * 监听单选按钮是否被选中, */ mRg_chat_smilingface_tab.setOnCheckedChangeListener(new OnCheckedChangeListener() { @Override public void onCheckedChanged(RadioGroup group, int checkedId) { current = checkedId; mV_myScrollView.moveToDest(checkedId); } }); /** * */ mV_myScrollView.setChangedListener(new IPageChangedListener() { @Override public void changedTo(int pageId) { current = pageId; ((RadioButton) mRg_chat_smilingface_tab.getChildAt(pageId)).setChecked(true); } }); }