本文整理了Java中android.widget.GridView.setStretchMode()
方法的一些代码示例,展示了GridView.setStretchMode()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。GridView.setStretchMode()
方法的具体详情如下:
包路径:android.widget.GridView
类名称:GridView
方法名:setStretchMode
暂无
代码示例来源:origin: stackoverflow.com
int numOfColms = feedbackQuestionSection.getFeedbackAnswerList().size() + 1; //No of Columns = No of Answers + 1 (Blank first Row First Column)
GridView gridView = (GridView) findViewById(R.id.gridview);
gridView.setOnItemClickListener(this);
gridView.setStretchMode(GridView.NO_STRETCH);
gridView.setNumColumns(numOfColms);
代码示例来源:origin: stackoverflow.com
GridView g;
g.setNumColumns(2);
g.setStretchMode(GridView.STRETCH_SPACING_UNIFORM);
代码示例来源:origin: recoilme/freemp
void updateGridView() {
int iDisplayWidth = Math.max(320, getResources().getDisplayMetrics().widthPixels);
int numColumns = iDisplayWidth / 310;
gridView.setColumnWidth((iDisplayWidth / numColumns));
gridView.setNumColumns(numColumns);
gridView.setStretchMode(GridView.NO_STRETCH);
gridView.invalidateViews();
}
代码示例来源:origin: recoilme/freemp
void updateGridView() {
int iDisplayWidth = Math.max(320, getResources().getDisplayMetrics().widthPixels);
int numColumns = iDisplayWidth / 310;
gridView.setColumnWidth((iDisplayWidth / numColumns));
gridView.setNumColumns(numColumns);
gridView.setStretchMode(GridView.NO_STRETCH);
gridView.invalidateViews();
}
代码示例来源:origin: stackoverflow.com
// create a gridview
GridView gridView= new GridView(this);
gridView.setLayoutParams(new GridView.LayoutParams(LayoutParams.FILL_PARENT, LayoutParams.FILL_PARENT));
gridView.setNumColumns(set number of columns here);
gridView.setColumnWidth(GridView.AUTO_FIT);
gridView.setStretchMode(GridView.STRETCH_COLUMN_WIDTH);
gridView.setAdapter(adapter);
代码示例来源:origin: bilibili/BiliShare
protected static GridView createShareGridView(final Context context, AdapterView.OnItemClickListener onItemClickListener) {
GridView grid = new GridView(context);
ListAdapter adapter = new ArrayAdapter<ShareTarget>(context, 0, shareTargets) {
// no need scroll
@Override
public View getView(int position, View convertView, ViewGroup parent) {
View view = LayoutInflater.from(parent.getContext()).inflate(R.layout.bili_socialize_shareboard_item, parent, false);
view.setBackgroundDrawable(null);
ImageView image = (ImageView) view.findViewById(R.id.bili_socialize_shareboard_image);
TextView platform = (TextView) view.findViewById(R.id.bili_socialize_shareboard_pltform_name);
ShareTarget target = getItem(position);
image.setImageResource(target.iconId);
platform.setText(target.titleId);
return view;
}
};
grid.setNumColumns(-1);
grid.setStretchMode(GridView.STRETCH_COLUMN_WIDTH);
grid.setColumnWidth(context.getResources().getDimensionPixelSize(R.dimen.bili_socialize_shareboard_size));
grid.setLayoutParams(new ViewGroup.LayoutParams(-1, -2));
grid.setSelector(R.drawable.bili_socialize_selector_item_background);
grid.setAdapter(adapter);
grid.setOnItemClickListener(onItemClickListener);
return grid;
}
代码示例来源:origin: dabutaizha/juzimi
protected static GridView createShareGridView(final Context context, AdapterView.OnItemClickListener onItemClickListener) {
GridView grid = new GridView(context);
ListAdapter adapter = new ArrayAdapter<ShareTarget>(context, 0, shareTargets) {
// no need scroll
@Override
public View getView(int position, View convertView, ViewGroup parent) {
View view = LayoutInflater.from(parent.getContext()).inflate(R.layout.shareboard_item, parent, false);
view.setBackgroundDrawable(null);
ImageView image = view.findViewById(R.id.shareboard_image);
TextView platform = view.findViewById(R.id.shareboard_pltform);
ShareTarget target = getItem(position);
image.setImageResource(target.iconId);
platform.setText(target.titleId);
return view;
}
};
grid.setNumColumns(3);
grid.setStretchMode(GridView.STRETCH_COLUMN_WIDTH);
grid.setColumnWidth(context.getResources().getDimensionPixelSize(R.dimen.shareboard_size));
grid.setLayoutParams(new ViewGroup.LayoutParams(-1, -2));
grid.setSelector(R.drawable.background_shareboard);
grid.setAdapter(adapter);
grid.setOnItemClickListener(onItemClickListener);
return grid;
}
代码示例来源:origin: jelic98/dynamico
gridView.setStretchMode(NO_STRETCH);
}else if(mode.equalsIgnoreCase("stretch_spacing")) {
gridView.setStretchMode(STRETCH_SPACING);
}else if(mode.equalsIgnoreCase("stretch_column_width")) {
gridView.setStretchMode(STRETCH_COLUMN_WIDTH);
}else if(mode.equalsIgnoreCase("stretch_spacing_uniform")) {
gridView.setStretchMode(STRETCH_SPACING_UNIFORM);
代码示例来源:origin: towavephone/MemoryCleaner
@Override public void showThemeChooseDialog() {
AlertDialog.Builder builder = DialogUtils.makeDialogBuilder(activity);
builder.setTitle(R.string.change_theme);
Integer[] res = new Integer[] { R.drawable.deep_purple_round,
R.drawable.brown_round, R.drawable.blue_round,
R.drawable.blue_grey_round, R.drawable.yellow_round,
R.drawable.red_round, R.drawable.pink_round,
R.drawable.green_round };
List<Integer> list = Arrays.asList(res);
ColorsListAdapter adapter = new ColorsListAdapter(getActivity(), list);
adapter.setCheckItem(
ThemeUtils.getCurrentTheme(activity).getIntValue());
GridView gridView = (GridView) LayoutInflater.from(activity)
.inflate(
R.layout.colors_panel_layout,
null);
gridView.setStretchMode(GridView.STRETCH_COLUMN_WIDTH);
gridView.setCacheColorHint(0);
gridView.setAdapter(adapter);
builder.setView(gridView);
final AlertDialog dialog = builder.show();
gridView.setOnItemClickListener((parent, view, position, id) -> {
dialog.dismiss();
mSettingPresenter.onThemeChoose(position);
});
}
代码示例来源:origin: stackoverflow.com
GridView grid = new GridView( this );
grid.setColumnWidth( UIScheme.cellSize );
grid.setVerticalSpacing( UIScheme.gap );
grid.setStretchMode( GridView.STRETCH_COLUMN_WIDTH );
grid.setNumColumns( GridView.AUTO_FIT );
代码示例来源:origin: stackoverflow.com
GridView grid = new GridView(this);
grid.setId(215236);
grid.setLayoutParams(new GridView.LayoutParams(LayoutParams.FILL_PARENT,LayoutParams.FILL_PARENT));
grid.setBackgroundColor(Color.WHITE);
grid.setColumnWidth(GridView.AUTO_FIT);
grid.setStretchMode(GridView.STRETCH_COLUMN_WIDTH);
代码示例来源:origin: TheMelody/LotteryTrend
/**
* 绑定顶部数据显示:顶部数据只显示在一行;
*/
private void bindHeaderData(){
mHeadData=new ArrayList();
//33个红球+16个蓝球;
for (int i=1;i<=49;i++){
if(i<=33){
//红球区域
mHeadData.add(""+i);
}else{
//蓝球区域
mHeadData.add(""+(i-33));
}
}
DataAdapter adapter= new DataAdapter(R.layout.gridview_item);
adapter.bindData(mHeadData,false);
int deltaDp=getResources().getDimensionPixelSize(R.dimen.item_wh);
//下面的代码是重新定位布局参数;让gridView数据都显示在一行;
LinearLayout.LayoutParams params = new LinearLayout.LayoutParams(adapter.getCount() * deltaDp,
LinearLayout.LayoutParams.WRAP_CONTENT);
mHeadGridView.setLayoutParams(params);
mHeadGridView.setColumnWidth(deltaDp);//列宽
mHeadGridView.setStretchMode(GridView.NO_STRETCH);//伸展模式
mHeadGridView.setNumColumns(adapter.getCount());//共有多少列
mHeadGridView.setAdapter(adapter);
}
代码示例来源:origin: stackoverflow.com
GridView gv = new GridView(context);
gv.setId(999999);
gv.setLayoutParams(new
GridView.LayoutParams(LayoutParams.FILL_PARENT,LayoutParams.FILL_PARENT));
gv.setBackgroundColor(Color.GREEN);
gv.setNumColumns(3);
gv.setColumnWidth(GridView.AUTO_FIT);
gv.setVerticalSpacing(5);
gv.setHorizontalSpacing(5);
gv.setStretchMode(GridView.STRETCH_COLUMN_WIDTH);
gv.setGravity(Gravity.CENTER);
代码示例来源:origin: stackoverflow.com
GridView grid = new GridView(this);
grid.setId(ViewIdentification.getId());
grid.setLayoutParams(new GridView.LayoutParams(LayoutParams.FILL_PARENT,LayoutParams.FILL_PARENT));
grid.setBackgroundColor(Color.WHITE);
grid.setNumColumns(3);
grid.setColumnWidth(GridView.AUTO_FIT);
grid.setVerticalSpacing(5);
grid.setHorizontalSpacing(5);
grid.setStretchMode(GridView.STRETCH_COLUMN_WIDTH);
代码示例来源:origin: AppLozic/Applozic-Android-SDK
public void createView() {
removeAllViews();
GridView gridView = new GridView(getContext());
LayoutParams params = new LayoutParams(ViewGroup.LayoutParams.WRAP_CONTENT, ViewGroup.LayoutParams.WRAP_CONTENT);
gridView.setLayoutParams(params);
gridView.setNumColumns(3);
gridView.setHorizontalSpacing(1);
gridView.setVerticalSpacing(1);
gridView.setStretchMode(GridView.STRETCH_COLUMN_WIDTH);
prepareAttachmentData(gridView);
gridView.setOnItemClickListener(this);
addView(gridView);
}
代码示例来源:origin: TheMelody/LotteryTrend
mFooterGridView.setLayoutParams(params);
mFooterGridView.setStretchMode(GridView.NO_STRETCH);//伸展模式
代码示例来源:origin: stackoverflow.com
gridView.setStretchMode(GridView.NO_STRETCH);
gridView.setPadding((int) padding, (int) padding, (int) padding,
(int) padding);
代码示例来源:origin: marzika/Snapprefs
@Override
protected void afterHookedMethod(final MethodHookParam param) throws Throwable {
if (!once){
View colorPickerView = (View) getObjectField(param.thisObject, "j");
outerOptionsLayout = new RelativeLayout(HookMethods.SnapContext);
final GridView innerOptionsView = new GridView(HookMethods.SnapContext);
innerOptionsView.setAdapter(new OptionsAdapter(HookMethods.SnapContext, mResources));
innerOptionsView.setNumColumns(5);
innerOptionsView.setHorizontalSpacing(px(2.0f));
innerOptionsView.setVerticalSpacing(px(5.0f));
innerOptionsView.setStretchMode(GridView.STRETCH_COLUMN_WIDTH);
innerOptionsView.setPadding(0,px(7.5f), px(1.0f), px(7.5f));
final RelativeLayout.LayoutParams outerOptionsLayoutParams = new RelativeLayout.LayoutParams(RelativeLayout.LayoutParams.WRAP_CONTENT, RelativeLayout.LayoutParams.WRAP_CONTENT);
outerOptionsLayoutParams.leftMargin = px(75.0f);
outerOptionsLayoutParams.rightMargin = px(25.0f);
outerOptionsLayout.setVisibility(View.VISIBLE);
outerOptionsLayout.setBackgroundDrawable(mResources.getDrawable(R.drawable.drawingbackground));
outerOptionsLayout.addView(innerOptionsView, GridLayout.LayoutParams.MATCH_PARENT, GridLayout.LayoutParams.MATCH_PARENT);
((RelativeLayout)colorPickerView.getParent().getParent()).addView(outerOptionsLayout, outerOptionsLayoutParams);
once = true;
}
}
});
代码示例来源:origin: AriesHoo/UIWidget
mGvContainer.setOverScrollMode(View.OVER_SCROLL_NEVER);
mGvContainer.setNumColumns(mNumColumns);
mGvContainer.setStretchMode(mStretchMode);
mGvContainer.setHorizontalSpacing(mHorizontalSpacing);
mGvContainer.setVerticalSpacing(mVerticalSpacing);
代码示例来源:origin: klinker24/Android-Blur-Launcher
gridview.setFastScrollEnabled(true);
gridview.setColumnWidth(iconSize);
gridview.setStretchMode(GridView.STRETCH_COLUMN_WIDTH);
内容来源于网络,如有侵权,请联系作者删除!