当前位置: 首页>>代码示例>>Java>>正文


Java GridView.setHorizontalSpacing方法代码示例

本文整理汇总了Java中android.widget.GridView.setHorizontalSpacing方法的典型用法代码示例。如果您正苦于以下问题:Java GridView.setHorizontalSpacing方法的具体用法?Java GridView.setHorizontalSpacing怎么用?Java GridView.setHorizontalSpacing使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在android.widget.GridView的用法示例。


在下文中一共展示了GridView.setHorizontalSpacing方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: createEmotionGridView

import android.widget.GridView; //导入方法依赖的package包/类
/**
 * 创建显示表情的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(GlobalOnItemClickManagerUtils.getInstance().getOnItemClickListener(getActivity(),emotion_map_type));
    return gv;
}
 
开发者ID:SiberiaDante,项目名称:EmotionApp,代码行数:24,代码来源:EmotionComplateFragment.java

示例2: onCreateView

import android.widget.GridView; //导入方法依赖的package包/类
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container,
                         Bundle savedInstanceState) {
    provider = getArguments().getParcelable(ARG_PROVIDER);
    String result = getSQLResult(getContext(), provider, getString(R.string.sql_injection));
    View rootView = inflater.inflate(R.layout.fragment_details_schema, container, false);
    if (getStatus(result)==100){
        //TODO add image view
        rootView.findViewById(R.id.tv_schema).setVisibility(View.VISIBLE);
    } else {
        LinearLayout linearLayout = (LinearLayout) rootView.findViewById(R.id.ll);
        Map<String, List<List<String>>> resultToMap = parseResultToMap(result);
        for (String name: resultToMap.keySet()){
            TextView tv = getFilledTextView(getContext(),name);
            linearLayout.addView(tv);
            GridView grid = new GridView(getContext());
            grid.setNumColumns(3);
            grid.setHorizontalSpacing(10);
            grid.setVerticalSpacing(10);
            grid.setStretchMode(GridView.STRETCH_COLUMN_WIDTH);
            grid.setGravity(View.TEXT_ALIGNMENT_CENTER);
            List<List<String>> list = resultToMap.get(name);
            grid.setAdapter(new GridAdapter(getContext(),list));
            grid.setLayoutParams(new ViewGroup.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, list.size()*35)); //TODO: remove int value
            linearLayout.addView(grid);
        }
    }
    return rootView;
}
 
开发者ID:AlexeyZatsepin,项目名称:CP-Tester,代码行数:30,代码来源:SchemaFragment.java

示例3: init

import android.widget.GridView; //导入方法依赖的package包/类
private void init(){
	cal = Calendar.getInstance();
	base = new RelativeLayout(context);
	base.setLayoutParams(new LayoutParams(LayoutParams.MATCH_PARENT,LayoutParams.WRAP_CONTENT));
	base.setMinimumHeight(50);
	
	base.setId(4);
	
	LayoutParams params = new LayoutParams(LayoutParams.WRAP_CONTENT,LayoutParams.WRAP_CONTENT);
	params.leftMargin = 16;
	params.topMargin = 50;
	params.addRule(RelativeLayout.ALIGN_PARENT_LEFT);
	params.addRule(RelativeLayout.CENTER_VERTICAL);
	prev = new ImageView(context);
	prev.setId(1);
	prev.setLayoutParams(params);
	prev.setImageResource(R.drawable.navigation_previous_item);
	prev.setOnClickListener(this);
	base.addView(prev);
	
	params = new LayoutParams(LayoutParams.WRAP_CONTENT,LayoutParams.WRAP_CONTENT);
	params.addRule(RelativeLayout.CENTER_HORIZONTAL);
	params.addRule(RelativeLayout.CENTER_VERTICAL);
	month = new TextView(context);
	month.setId(2);
	month.setLayoutParams(params);
	month.setTextAppearance(context, android.R.attr.textAppearanceLarge);
	month.setText(cal.getDisplayName(Calendar.MONTH, Calendar.LONG, Locale.getDefault())+" "+cal.get(Calendar.YEAR));
	month.setTextSize(25);
	
	base.addView(month);
	
	params = new LayoutParams(LayoutParams.WRAP_CONTENT,LayoutParams.WRAP_CONTENT);
	params.rightMargin = 16;
	params.topMargin = 50;
	params.addRule(RelativeLayout.ALIGN_PARENT_RIGHT);
	params.addRule(RelativeLayout.CENTER_VERTICAL);
	next = new ImageView(context);
	next.setImageResource(R.drawable.navigation_next_item);
	next.setLayoutParams(params);
	next.setId(3);
	next.setOnClickListener(this);
	
	base.addView(next);
	
	addView(base);
	
	params = new LayoutParams(LayoutParams.WRAP_CONTENT,LayoutParams.WRAP_CONTENT);
	params.bottomMargin = 20;
	params.addRule(RelativeLayout.ALIGN_PARENT_LEFT);
	params.addRule(RelativeLayout.ALIGN_PARENT_BOTTOM);
	params.addRule(RelativeLayout.BELOW, base.getId());
	
	calendar = new GridView(context);
	calendar.setLayoutParams(params);
	calendar.setVerticalSpacing(4);
	calendar.setHorizontalSpacing(4);
	calendar.setNumColumns(7);
	calendar.setChoiceMode(GridView.CHOICE_MODE_SINGLE);
	calendar.setDrawSelectorOnTop(true);
	calendar.setFocusable(false);

	mAdapter = new CalendarAdapter(context,cal);
	calendar.setAdapter(mAdapter);
	calendar.setOnTouchListener(new OnTouchListener() {
		
        @Override
        public boolean onTouch(View v, MotionEvent event) {
            return calendarGesture.onTouchEvent(event);
        }
    });

	addView(calendar);
}
 
开发者ID:ur13l,项目名称:Guanajoven,代码行数:75,代码来源:ExtendedCalendarView.java

示例4: initViews

import android.widget.GridView; //导入方法依赖的package包/类
private void initViews() {
    mBtnBack = (Button) findViewById(R.id.btn_puzzle_main_back);
    mBtnImage = (Button) findViewById(R.id.btn_puzzle_main_img);
    mBtnRestart = (Button) findViewById(R.id.btn_puzzle_main_restart);
    //flag是否显示原图
    mIsShowImg = false;
    mGvPuzzleMainDetail = (GridView) findViewById(
            R.id.gv_puzzle_main_detail);
            // 设置为N*N显示
    mGvPuzzleMainDetail.setNumColumns(TYPE);
    RelativeLayout.LayoutParams gridParams = new RelativeLayout.LayoutParams(mPicSelected.getWidth(),mPicSelected.getHeight());
    //水平居中
    gridParams.addRule(RelativeLayout.CENTER_HORIZONTAL);
    //其他格式属性
    gridParams.addRule(RelativeLayout.BELOW,R.id.ll_puzzle_main_spinner);
    //Grid显示
    mGvPuzzleMainDetail.setLayoutParams(gridParams);
    mGvPuzzleMainDetail.setHorizontalSpacing(0);
    mGvPuzzleMainDetail.setVerticalSpacing(0);
    //TV步数
    mTvPuzzleMainCounts = (TextView) findViewById(R.id.tv_puzzle_main_counts);
    mTvPuzzleMainCounts.setText(""+ COUNT_INDEX);
    //Tv计时器
    mTvTimer = (TextView) findViewById(R.id.tv_puzzle_main_time);
    mTvTimer.setText("0秒");
    //添加显示的原图
    addImgView();

}
 
开发者ID:Yobin123,项目名称:PinTuGame,代码行数:30,代码来源:PuzzleMain.java


注:本文中的android.widget.GridView.setHorizontalSpacing方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。