Java Code Examples for android.widget.GridView#setPadding()
The following examples show how to use
android.widget.GridView#setPadding() .
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: EmotionComplateFragment.java From timecat with Apache License 2.0 | 7 votes |
/** * 创建显示表情的GridView */ private GridView createEmotionGridView(List<String> emotionNames, int gvWidth, int padding, int itemWidth, int gvHeight) { // 创建GridView GridView gv = new GridView(getActivity()); //设置点击背景透明 gv.setSelector(android.R.color.transparent); //设置7列 gv.setNumColumns(7); gv.setPadding(padding, padding, padding, padding); gv.setHorizontalSpacing(padding); gv.setVerticalSpacing(padding * 2); //设置GridView的宽高 ViewGroup.LayoutParams params = new ViewGroup.LayoutParams(gvWidth, gvHeight); gv.setLayoutParams(params); // 给GridView设置表情图片 EmotionGridViewAdapter adapter = new EmotionGridViewAdapter(getActivity(), emotionNames, itemWidth,emotion_map_type); gv.setAdapter(adapter); //设置全局点击事件 gv.setOnItemClickListener(GlobalOnItemClickManager.getInstance(getActivity()) .getOnItemClickListener(emotion_map_type)); return gv; }
Example 2
Source File: ChatEmotionFragment.java From chatui with Apache License 2.0 | 6 votes |
/** * 创建显示表情的GridView */ private GridView createEmotionGridView(List<String> emotionNames, int gvWidth, int padding, int itemWidth, int gvHeight) { // 创建GridView GridView gv = new GridView(getActivity()); //设置点击背景透明 gv.setSelector(android.R.color.transparent); //设置7列 gv.setNumColumns(8); gv.setPadding(padding, padding, padding, padding); gv.setHorizontalSpacing(padding); gv.setVerticalSpacing(padding * 2); //设置GridView的宽高 ViewGroup.LayoutParams params = new ViewGroup.LayoutParams(gvWidth, gvHeight); gv.setLayoutParams(params); // 给GridView设置表情图片 EmotionGridViewAdapter adapter = new EmotionGridViewAdapter(getActivity(), emotionNames, itemWidth); gv.setAdapter(adapter); //设置全局点击事件 gv.setOnItemClickListener(GlobalOnItemClickManagerUtils.getInstance(getActivity()).getOnItemClickListener()); return gv; }
Example 3
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 4
Source File: YayaEmoGridView.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(4); gridView.setVerticalScrollBarEnabled(false); gridView.setHorizontalScrollBarEnabled(false); gridView.setPadding(8, 8, 8, 0); gridView.setVerticalSpacing(20); gridView.setSelector(new ColorDrawable(Color.TRANSPARENT)); gridView.setAdapter(new YayaEmoGridViewAdapter(_context, getGridViewData(index))); gridView.setOnItemClickListener(new OnItemClickListener() { @Override public void onItemClick(AdapterView<?> parent, View view, int position, long id) { int start = index * SysConstant.yayaPageSize; onEmoGridViewItemClick.onItemClick(position + start, index); } }); return gridView; }
Example 5
Source File: MainViewHelper.java From palmsuda with Apache License 2.0 | 6 votes |
private GridView createGridView(List<ModuleItem> items) { GridView gView = (GridView) mInflater.inflate(R.layout.main_gridview, null); gView.setVerticalSpacing(vspace); gView.setPadding(0, vspace / 2, 0, 0); GdvAdapter adapter = new GdvAdapter(mActivity, mActivity.getImageWorker(), gView); adapter.setData(items); gView.setAdapter(adapter); gView.setOnItemClickListener(new AdapterView.OnItemClickListener() { @Override public void onItemClick(AdapterView<?> arg0, View arg1, int arg2, long arg3) { ModuleItem item = (ModuleItem) arg0.getAdapter().getItem(arg2); mActivity.gridViewClick(mAItem, item); } }); return gView; }
Example 6
Source File: ChatEmotionFragment.java From Socket.io-FLSocketIM-Android with MIT License | 5 votes |
private GridView createEmotionGridView(final List<String> emotionNames, int gvWidth, int padding, int itemWidth, int gvHeight) { GridView gv = new GridView(mContext); gv.setNumColumns(8); gv.setPadding(padding, padding, padding, padding); gv.setHorizontalSpacing(padding); gv.setVerticalSpacing(padding*2); ViewGroup.LayoutParams params = new ViewGroup.LayoutParams(gvWidth, gvHeight); gv.setLayoutParams(params); EmotionGridViewAdapter adapter = new EmotionGridViewAdapter(mContext, emotionNames, itemWidth); gv.setAdapter(adapter); gv.setOnItemClickListener(new AdapterView.OnItemClickListener() { @Override public void onItemClick(AdapterView<?> adapterView, View view, int i, long l) { if (clickCallBack == null) { return; } if (view instanceof ImageView) { clickCallBack.onClickDelete(); } else { String emotion = emotionNames.get(i); clickCallBack.onClickEmotion(emotion); } } }); return gv; }
Example 7
Source File: GridExampleFragment.java From ShadowDrawable with MIT License | 5 votes |
@Nullable @Override public View onCreateView(LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) { gridView = new GridView(getActivity()); gridView.setClipToPadding(false); int padding = 18 * 3; gridView.setPadding(padding, padding, padding, padding); return gridView; }
Example 8
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 9
Source File: SuperGridview.java From UltimateAndroid with Apache License 2.0 | 5 votes |
@Override protected void initAbsListView(View v) { View listView = v.findViewById(android.R.id.list); if (listView instanceof GridView) mList = (GridView) listView; else throw new IllegalArgumentException(listView.getClass().getName()); if (mList!=null) { getList().setNumColumns(mColumns); getList().setVerticalSpacing(mVerticalSpacing); getList().setHorizontalSpacing(mHorizontalSpacing); getList().setHorizontalSpacing((int) mDividerHeight); getList().setVerticalSpacing((int) mDividerHeight); mList.setClipToPadding(mClipToPadding); mList.setOnScrollListener(this); if (mSelector != 0) mList.setSelector(mSelector); if (mPadding != -1.0f) { mList.setPadding(mPadding, mPadding, mPadding, mPadding); } else { mList.setPadding(mPaddingLeft, mPaddingTop, mPaddingRight, mPaddingBottom); } mList.setScrollBarStyle(mScrollbarStyle); } }
Example 10
Source File: AlbumActivity.java From socialauth-android with MIT License | 5 votes |
/** * collection of grid properties */ @SuppressWarnings("static-access") public void getGridProperties(GridView view) { view.setNumColumns(3); view.setVerticalSpacing(5); view.setScrollBarStyle(view.SCROLLBARS_OUTSIDE_OVERLAY); view.setScrollingCacheEnabled(false); view.setGravity(Gravity.TOP); view.setSelector(new ColorDrawable(Color.parseColor("#00000000"))); view.setClipChildren(true); view.setPadding(5, 5, 5, 5); }
Example 11
Source File: PictureElement.java From sana.mobile with BSD 3-Clause "New" or "Revised" License | 4 votes |
/** * {@inheritDoc} */ @Override protected View createView(Context c) { imageGrid = new GridView(c); Log.i(TAG, "Looking up for encounter: " + getProcedure().getInstanceUri()); String procedureId = getProcedure().getInstanceUri().getLastPathSegment(); Log.w(TAG, "PictureELement: Encounter id " + procedureId); String whereStr; if (!UUIDUtil.isValid(procedureId)) whereStr = ImageSQLFormat.ENCOUNTER_ID + " = ? AND " + ImageSQLFormat.ELEMENT_ID + " = ? AND " + ImageSQLFormat.FILE_VALID + " = ?"; else whereStr = ImageSQLFormat.ENCOUNTER_ID + " = '?' AND " + ImageSQLFormat.ELEMENT_ID + " = ? AND " + ImageSQLFormat.FILE_VALID + " = ?"; Cursor cursor = c.getContentResolver().query( SanaDB.ImageSQLFormat.CONTENT_URI, new String[]{ImageSQLFormat._ID}, whereStr, new String[]{procedureId, id, "1"}, null); // HAXMODE -- if we don't do this we leak the Cursor if (c instanceof Activity) { ((Activity) c).startManagingCursor(cursor); } imageAdapter = new ScalingImageAdapter(c, cursor, THUMBNAIL_SCALE_FACTOR); imageGrid.setAdapter(imageAdapter); imageGrid.setNumColumns(3); imageGrid.setVerticalSpacing(5); imageGrid.setPadding(5, 0, 0, 0); imageGrid.setOnItemClickListener(this); imageGrid.setOnItemLongClickListener(this); //imageGrid.setTranscriptMode(imageGrid.TRANSCRIPT_MODE_ALWAYS_SCROLL); cameraButton = new Button(c); cameraButton.setText(R.string.btn_add_photo); cameraButton.setOnClickListener(this); imageReview = new ImagePreviewDialog(c); LinearLayout picContainer = new LinearLayout(c); picContainer.setOrientation(LinearLayout.VERTICAL); if (question == null) { question = c.getString(R.string.question_standard_picture_element); } //Set question TextView tv = new TextView(c); tv.setText(String.format("%s: %s", id, question)); tv.setGravity(Gravity.CENTER); tv.setTextAppearance(c, android.R.style.TextAppearance_Medium); //Add to layout picContainer.addView(tv, new LinearLayout.LayoutParams(-1, -1, 0.1f)); //picContainer.addView(imageView, new LinearLayout.LayoutParams(-1,-1,0.1f)); //Add button picContainer.addView(cameraButton, new LinearLayout.LayoutParams(-1, -1, 0.1f)); picContainer.addView(imageGrid, new LinearLayout.LayoutParams(-1, 210)); //LayoutParams(-1,-1,0.8f)); picContainer.setWeightSum(1.0f); return picContainer; }
Example 12
Source File: TabMenu.java From coolreader with MIT License | 4 votes |
public TabMenu(Context context,OnItemClickListener titleClick,OnItemClickListener bodyClick, MenuTitleAdapter titleAdapter,int colorBgTabMenu,int aniTabMenu) { super(context); mLayout = new LinearLayout(context); mLayout.setOrientation(LinearLayout.VERTICAL); //标题选项栏 gvTitle = new GridView(context); gvTitle.setLayoutParams(new LayoutParams(LayoutParams.FILL_PARENT, LayoutParams.WRAP_CONTENT)); gvTitle.setNumColumns(titleAdapter.getCount()); gvTitle.setStretchMode(GridView.STRETCH_COLUMN_WIDTH); gvTitle.setVerticalSpacing(1); gvTitle.setHorizontalSpacing(1); gvTitle.setGravity(Gravity.CENTER); gvTitle.setOnItemClickListener(titleClick); gvTitle.setAdapter(titleAdapter); gvTitle.setSelector(new ColorDrawable(Color.TRANSPARENT));//选中的时候为透明色 this.titleAdapter=titleAdapter; //子选项栏 gvBody = new GridView(context); gvBody.setLayoutParams(new LayoutParams(LayoutParams.FILL_PARENT,LayoutParams.WRAP_CONTENT)); gvBody.setSelector(new ColorDrawable(Color.TRANSPARENT));//选中的时候为透明色 gvBody.setNumColumns(4); gvBody.setStretchMode(GridView.STRETCH_COLUMN_WIDTH); gvBody.setVerticalSpacing(10); gvBody.setHorizontalSpacing(10); gvBody.setPadding(5, 5, 5, 5); gvBody.setGravity(Gravity.CENTER); gvBody.setOnItemClickListener(bodyClick); mLayout.addView(gvTitle); mLayout.addView(gvBody); //设置默认项 this.setContentView(mLayout); this.setWidth(LayoutParams.FILL_PARENT); this.setHeight(LayoutParams.WRAP_CONTENT); this.setBackgroundDrawable(new ColorDrawable(colorBgTabMenu));// 设置TabMenu菜单背景 this.setAnimationStyle(aniTabMenu); this.setFocusable(true);// menu菜单获得焦点 如果没有获得焦点menu菜单中的控件事件无法响应 }