Java 类android.support.v7.widget.GridLayout 实例源码

项目:NumberPadTimePicker    文件:NumberPadTimePickerBottomSheetComponent.java   
@Override
public void run() {
    switch (mBackspaceLocation) {
        case LOCATION_HEADER:
            break;
        case LOCATION_FOOTER:
            ((ViewGroup) mHeader).removeView(mBackspace);
            // The row of the cell in which the backspace key should go.
            // This specifies the row index, which spans one increment,
            // and indicates the cell should be filled along the row
            // (horizontal) axis.
            final GridLayout.Spec rowSpec = GridLayout.spec(
                    mNumberPad.getRowCount() - 1, GridLayout.FILL);
            // The column of the cell in which the backspace key should go.
            // This specifies the column index, which spans one increment,
            // and indicates the cell should be filled along the column
            // (vertical) axis.
            final GridLayout.Spec columnSpec = GridLayout.spec(
                    mNumberPad.getColumnCount() - 1, GridLayout.FILL);
            mNumberPad.addView(mBackspace, new GridLayout.LayoutParams(
                    rowSpec, columnSpec));
            break;
    }
}
项目:Harmony-Music-Player    文件:HomeFragment.java   
private void populateFavorites(List<Song> favorites)
{
    if(favorites != null)
    {
        GridLayout favoritesLayout = (GridLayout)getView().findViewById(R.id.favorites_layout);

        float favWidth = getContext().getResources().getDimension(R.dimen.album_grid_item_width);
        float favHeight = getContext().getResources().getDimension(R.dimen.album_grid_item_height);

        LayoutInflater inflater = LayoutInflater.from(getContext());
        int max = Math.min(favorites.size(),3);
        for(int i = 0; i < max; i++)
        {
            Song song = favorites.get(i);
            View v = inflater.inflate(R.layout.album_grid_item, favoritesLayout, false);
            favoritesLayout.addView(v);

            ImageView artworkView = (ImageView) v.findViewById(R.id.album_artwork);
        }
    }
}
项目:MaterialWeather    文件:MyAdapter.java   
public SuggestionViewHolder(View itemView) {
    super(itemView);

    suggestionRelative = (RelativeLayout) itemView.findViewById(R.id.suggestion_detail);
    suggestionDetailIcon = (ImageView) itemView.findViewById(R.id.suggestion_detail_icon);
    suggestionDetailInfo = (TextView) itemView.findViewById(R.id.suggestion_detail_info);
    suggestionDetailIntroduction = (TextView) itemView.findViewById(R.id.suggestion_detail_introduction);

    suggestionGrid = (GridLayout) itemView.findViewById(R.id.suggestion_grid);
    for (int i = 0; i < 6; i++) {
        View view = View.inflate(mContext, R.layout.item_suggestion_grid, null);
        view.setId(R.id.suggestion_view_id + i);
        GridLayout.LayoutParams params = new GridLayout.LayoutParams();
        params.columnSpec = GridLayout.spec(GridLayout.UNDEFINED, 1f);
        params.setMargins(90, 15, 0, 15);//设置边距
        view.setLayoutParams(params);
        suggestionType[i] = (TextView) view.findViewById(R.id.suggestion_type);
        suggestionInfo[i] = (TextView) view.findViewById(R.id.suggestion_info);
        suggestionIcon[i] = (ImageView) view.findViewById(R.id.suggestion_icon);
        suggestionGrid.addView(view);
    }
}
项目:colorblocks    文件:ColorPickerFragment.java   
public void generateColorBlocks(int[] colors, GridLayout layout) {
    int column = 3;
    int total = colors.length;
    int rows = total / column;

    layout.setColumnCount(column);
    layout.setRowCount(rows + 1);

    for (int i = 0, c = 0, r = 0; i < total; i++, c++) {
        if (c == column) {
            c = 0;
            r++;
        }

        GridLayout.LayoutParams layoutParams = new GridLayout.LayoutParams();
        layoutParams.rowSpec = GridLayout.spec(r);
        layoutParams.columnSpec = GridLayout.spec(c);
        layoutParams.setGravity(Gravity.CENTER);

        ImageView imageView = new ImageView(layout.getContext());
        imageView.setBackgroundColor(colorsParam[i]);
        imageView.setLayoutParams(layoutParams);
        layout.addView(imageView);
    }
}
项目:BottomSheetPickers    文件:NumberPadTimePickerBottomSheetComponent.java   
@Override
public void run() {
    switch (mBackspaceLocation) {
        case LOCATION_HEADER:
            break;
        case LOCATION_FOOTER:
            ((ViewGroup) mHeader).removeView(mBackspace);
            // The row of the cell in which the backspace key should go.
            // This specifies the row index, which spans one increment,
            // and indicates the cell should be filled along the row
            // (horizontal) axis.
            final GridLayout.Spec rowSpec = GridLayout.spec(
                    mNumberPad.getRowCount() - 1, GridLayout.FILL);
            // The column of the cell in which the backspace key should go.
            // This specifies the column index, which spans one increment,
            // and indicates the cell should be filled along the column
            // (vertical) axis.
            final GridLayout.Spec columnSpec = GridLayout.spec(
                    mNumberPad.getColumnCount() - 1, GridLayout.FILL);
            mNumberPad.addView(mBackspace, new GridLayout.LayoutParams(
                    rowSpec, columnSpec));
            break;
    }
}
项目:PokeMVVM    文件:TableCardLayout.java   
public void setData(Collection<Row> rows) {
    gridLayout.removeViews(1, gridLayout.getChildCount() - 1);
    for (Row row : rows) {
        {
            TextView nameView = new TextView(getContext());
            TextViewCompat.setTextAppearance(nameView, android.support.v7.appcompat.R.style.TextAppearance_AppCompat_Body1);
            nameView.setText(row.name());
            GridLayout.LayoutParams params = new GridLayout.LayoutParams();
            params.columnSpec = GridLayout.spec(GridLayout.UNDEFINED, 1f);
            gridLayout.addView(nameView, params);
        }
        {
            TextView valueView = new TextView(getContext());
            TextViewCompat.setTextAppearance(valueView, android.support.v7.appcompat.R.style.TextAppearance_AppCompat_Body1);
            valueView.setText(row.value());
            gridLayout.addView(valueView);
        }
    }
}
项目:PackageTracker    文件:FetchTimeTask.java   
@Override
protected void onPostExecute(TimeSearchResult timeSearchResult) {
    if (timeSearchResult == null) {
        Log.i(TAG, "onPostExecute: 失败 查询时效 获得空结果");
        return;
    }
    Log.d(TAG, "onPostExecute: 成功 查询时效 获得数量: " + timeSearchResult.getEntries().size());
    GridLayout gridLayout = mActivity.getGridLayout();
    gridLayout.removeAllViews();
    gridLayout.setColumnCount(2);
    for (TimeSearchResult.Entry entry : timeSearchResult.getEntries()) {
        String companyName = entry.getCompanyName();
        String time = entry.getTime();
        HttpUrl logoUrl = HttpUrl.parse(entry.getCompanyLogoUrl());
        CardView card =
            (CardView) mActivity.getLayoutInflater().inflate(R.layout.card_time, mActivity.getGridLayout(), false);
        ImageView logo = (ImageView) card.findViewById(R.id.logo);
        TextView companyNameText = (TextView) card.findViewById(R.id.company_name);
        TextView timeText = (TextView) card.findViewById(R.id.time);

        fetcher.DownloadImage(this, logoUrl, logo);
        companyNameText.setText(companyName.trim());
        timeText.setText(time.trim());
        mActivity.getGridLayout().addView(card);
    }
}
项目:GridBuilder    文件:GridBuilder.java   
/**
 * 将倒影布局添加到GridLayout容器中
 */
private void addReflectionImageView() {
    mReflectionImageView = new ImageView(mContext);

    GridLayout.LayoutParams layoutParams = new GridLayout.LayoutParams();
    layoutParams.width = mColumnCount * mBaseWidth
            + ((mColumnCount > 1 ? mHorizontalMargin * (mColumnCount - 1) : 0));
    layoutParams.height = mBaseHeight;
    layoutParams.rowSpec = GridLayout.spec(mRowCount - 1, 1);
    layoutParams.columnSpec = GridLayout.spec(0, mColumnCount);

    mReflectionImageView.setLayoutParams(layoutParams);
    mReflectionImageView.setScaleType(ImageView.ScaleType.FIT_XY);

    this.refreshReflection(0);
    mGridLayout.addView(mReflectionImageView);

    mReflectionImageView.setVisibility(mVisibility);
}
项目:AppPlus    文件:ColorChooseDialog.java   
@NonNull
@Override
public Dialog onCreateDialog(Bundle savedInstanceState) {
    int preselect = getArguments().getInt("preselect");
    View view = View.inflate(getActivity(), R.layout.dialog_color_chooser, null);
    mColors = initColors();

    GridLayout gridLayout = (GridLayout) view.findViewById(R.id.grid);

    for (int i = 0; i < mColors.length; i++) {
        gridLayout.addView(getColorItemView(getActivity(), i, i == preselect));
    }
    AlertDialog dialog = new AlertDialog.Builder(getActivity())
            .setTitle(R.string.color_chooser)
            .setView(view)
            .show();
    return dialog;
}
项目:365browser    文件:PaymentRequestSection.java   
@Override
protected void createMainSectionContent(LinearLayout mainSectionLayout) {
    Context context = mainSectionLayout.getContext();

    // Add a label that will be used to indicate that the total cart price has been updated.
    addUpdateText(mainSectionLayout);

    // The breakdown is represented by an end-aligned GridLayout that takes up only as much
    // space as it needs.  The GridLayout ensures a consistent margin between the columns.
    mBreakdownLayout = new GridLayout(context);
    mBreakdownLayout.setColumnCount(2);
    LayoutParams breakdownParams =
            new LayoutParams(LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT);
    breakdownParams.gravity = Gravity.END;
    mainSectionLayout.addView(mBreakdownLayout, breakdownParams);

    // Sets the summary right text view takes the same available space as the summary left
    // text view.
    LinearLayout.LayoutParams rightTextViewLayoutParams =
            (LinearLayout.LayoutParams) getSummaryRightTextView().getLayoutParams();
    rightTextViewLayoutParams.width = 0;
    rightTextViewLayoutParams.weight = 1f;
}
项目:365browser    文件:PaymentRequestSection.java   
private View createOptionIcon(GridLayout parent, int rowIndex, boolean editIconExists) {
    // The icon has a pre-defined width.
    ImageView optionIcon = new ImageView(parent.getContext());
    optionIcon.setImportantForAccessibility(IMPORTANT_FOR_ACCESSIBILITY_NO);
    if (mOption.isEditable()) {
        optionIcon.setMaxWidth(mEditableOptionIconMaxWidth);
    } else {
        optionIcon.setMaxWidth(mNonEditableOptionIconMaxWidth);
    }
    optionIcon.setAdjustViewBounds(true);
    optionIcon.setImageDrawable(mOption.getDrawableIcon());

    // Place option icon at column three if no edit icon.
    int columnStart = editIconExists ? 2 : 3;
    GridLayout.LayoutParams iconParams =
            new GridLayout.LayoutParams(GridLayout.spec(rowIndex, 1, GridLayout.CENTER),
                    GridLayout.spec(columnStart, 1, GridLayout.CENTER));
    iconParams.topMargin = mVerticalMargin;
    parent.addView(optionIcon, iconParams);

    optionIcon.setOnClickListener(OptionSection.this);
    return optionIcon;
}
项目:commcare-android    文件:EntityViewTile.java   
private void addBuffersToView(Context context, int count, boolean isRow) {
    for (int i = 0; i < count; i++) {
        GridLayout.LayoutParams gridParams;
        if (isRow) {
            gridParams = new GridLayout.LayoutParams(GridLayout.spec(i), GridLayout.spec(0));
            gridParams.width = 1;
            gridParams.height = (int)cellHeight;
        } else {
            gridParams = new GridLayout.LayoutParams(GridLayout.spec(0), GridLayout.spec(i));
            gridParams.width = (int)cellWidth;
            gridParams.height = 1;
        }

        Space space = new Space(context);
        space.setLayoutParams(gridParams);
        this.addView(space, gridParams);
    }
}
项目:commcare-android    文件:EntityViewTile.java   
private void addFieldView(Context context, String form,
                          GridStyle style, GridCoordinate coordinateData, String fieldString,
                          String sortField, int index) {
    if (coordinatesInvalid(coordinateData)) {
        return;
    }

    ViewId uniqueId = ViewId.buildTableViewId(coordinateData.getX(), coordinateData.getY(), false);
    GridLayout.LayoutParams gridParams = getLayoutParamsForField(coordinateData);

    View view = getView(context, style, form, fieldString, uniqueId, sortField,
            gridParams.width, gridParams.height);

    if (!(view instanceof ImageView)) {
        gridParams.height = LayoutParams.WRAP_CONTENT;
    }

    view.setLayoutParams(gridParams);
    mFieldViews[index] = view;
    this.addView(view, gridParams);
}
项目:nextgislogger    文件:InfoSensorsFragment.java   
private void fillSensorsTextViews(String source) {
    ArrayList<InfoItem> infoItemArray = getData();
    for (int i = 0; i < mLayoutData.getChildCount(); i++) {
        InfoItem item = infoItemArray.get(i);

        if (!item.getTitle().equals(source))
            continue;

        LinearLayout layout = (LinearLayout) mLayoutData.getChildAt(i);
        GridLayout values = (GridLayout) layout.findViewById(R.id.gl_values);

        for (int j = 0; j < item.size(); j++) {
            TextView data = (TextView) values.getChildAt(j);
            InfoColumn column = item.getColumns().get(j);
            setValue(data, column);
        }
    }
}
项目:Amazing    文件:Sudoku.java   
private void updateView() {
    removeAllViews();// remove all views
    int size = urls != null ? urls.size() : 0;
    int columnCount = getCol(size);
    for (int i = 0; i < size; ++i) {
        GridLayout.Spec row = GridLayout.spec(i / columnCount);
        GridLayout.Spec col = GridLayout.spec(i % columnCount, 1.0f);
        ImageView imageView = getImageView(i);
        //由于宽(即列)已经定义权重比例 宽设置为0 保证均分
        GridLayout.LayoutParams layoutParams = new GridLayout.LayoutParams(new ViewGroup.LayoutParams(0,
                ViewGroup.LayoutParams.WRAP_CONTENT));
        layoutParams.rowSpec = row;
        layoutParams.columnSpec = col;

        layoutParams.setMargins(margin, margin, margin, margin);
        addView(imageView, layoutParams);
    }

    getViewTreeObserver().addOnGlobalLayoutListener(new ViewTreeObserver.OnGlobalLayoutListener() {
        @Override
        public void onGlobalLayout() {
            ViewGroup.LayoutParams lp = getLayoutParams();
            if (getHeight() > 0 && lp.height == ViewGroup.LayoutParams.WRAP_CONTENT) {
                lp.height = getHeight();
                setLayoutParams(lp);
                getViewTreeObserver().removeOnGlobalLayoutListener(this);
            }
        }
    });
}
项目:PeSanKita-android    文件:ColorPreference.java   
@Override
public Dialog onCreateDialog(Bundle savedInstanceState) {
  LayoutInflater layoutInflater = LayoutInflater.from(getActivity());
  View rootView = layoutInflater.inflate(R.layout.color_preference_items, null);

  mColorGrid = (GridLayout) rootView.findViewById(R.id.color_grid);
  mColorGrid.setColumnCount(mPreference.mNumColumns);
  repopulateItems();

  return new AlertDialog.Builder(getActivity())
      .setView(rootView)
      .create();
}
项目:Cable-Android    文件:ColorPreference.java   
@Override
public Dialog onCreateDialog(Bundle savedInstanceState) {
  LayoutInflater layoutInflater = LayoutInflater.from(getActivity());
  View rootView = layoutInflater.inflate(R.layout.color_preference_items, null);

  mColorGrid = (GridLayout) rootView.findViewById(R.id.color_grid);
  mColorGrid.setColumnCount(mPreference.mNumColumns);
  repopulateItems();

  return new AlertDialog.Builder(getActivity())
      .setView(rootView)
      .create();
}
项目:openedt    文件:MainActivity.java   
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState)
{
    ArrayList<Week> weeks = new Gson().fromJson(getArguments().getString(BUNDLE_WEEKS, ""), new TypeToken<ArrayList<Week>>() {}.getType());

    View view = inflater.inflate(R.layout.activity_main_home_fragment, container, false);
    ButterKnife.bind(this, view);

    SimpleDateFormat format = TimeUtils.createLongDateFormat();
    Calendar cal = Calendar.getInstance();

    date.setText(WordUtils.capitalize(format.format(new Date())));
    week.setText(String.format("Semaine %d", cal.get(Calendar.WEEK_OF_YEAR)));

    ArrayList<WrapperEventWeek> wrappers = WeekManager.getNextEvents(weeks, 1);

    for (WrapperEventWeek wrap : wrappers)
    {
        CardView card = new CardView(getContext());

        EventView eventView = new EventView(getContext(), EventView.EventViewType.CONDENSED);

        eventView.setData(wrap.getEvent(), wrap.getWeek());
        card.addView(eventView);

        GridLayout.LayoutParams params = new GridLayout.LayoutParams();
        params.columnSpec = GridLayout.spec(GridLayout.UNDEFINED, 1f);
        params.setGravity(Gravity.FILL_VERTICAL);
        int margin = UIUtils.dp(getContext(), 10);
        params.setMargins(margin, margin, margin, margin);
        card.setLayoutParams(params);

        daysContainer.addView(card);
    }

    return view;
}
项目:truth-android    文件:GridLayoutSubject.java   
public static SubjectFactory<GridLayoutSubject, GridLayout> type() {
  return new SubjectFactory<GridLayoutSubject, GridLayout>() {
    @Override
    public GridLayoutSubject getSubject(FailureStrategy fs, GridLayout that) {
      return new GridLayoutSubject(fs, that);
    }
  };
}
项目:PokeMVVM    文件:TableCardLayout.java   
public TableCardLayout(Context context, AttributeSet attrs) {
    super(context, attrs);
    int leftRightPadding = getResources().getDimensionPixelOffset(R.dimen.padding_normal);
    int topBottomPadding = getResources().getDimensionPixelOffset(R.dimen.padding_three_halves);
    setContentPadding(leftRightPadding, topBottomPadding, leftRightPadding, topBottomPadding);

    gridLayout = (GridLayout) LayoutInflater.from(getContext()).inflate(R.layout.pokemon_table_card, this, false);
    titleView = (TextView) gridLayout.findViewById(R.id.title);
    addView(gridLayout);

    if (attrs != null) {
        TypedArray a = context.obtainStyledAttributes(attrs, R.styleable.TableCardLayout);
        String title = a.getString(R.styleable.TableCardLayout_android_title);
        if (title != null) {
            titleView.setText(title);
        }
        a.recycle();
    }

    if (isInEditMode()) {
        setData(Arrays.asList(
                new Row("speed", "45"),
                new Row("special-defense", "65"),
                new Row("special-attack", "65"),
                new Row("defense", "49"),
                new Row("attack", "49"),
                new Row("hp", "45")
        ));
    }
}
项目:smoothnovelreader    文件:SimpleDrawableChooserDialog.java   
@Override
public Dialog onCreateDialog(Bundle savedInstanceState) {
    MaterialDialog dialog = new MaterialDialog.Builder(getActivity())
            .title(R.string.dialog_choose_read_bg_color)
            .theme(mTheme)
            .autoDismiss(false)
            .customView(R.layout.dialog_color_chooser, false)
            .build();


    final GridLayout list = (GridLayout) dialog.getCustomView().findViewById(R.id.grid);
    final int preselect = getArguments().getInt("preselect", -1);

    for (int i = 0; i < list.getChildCount(); i++) {
        FrameLayout child = (FrameLayout) list.getChildAt(i);
        if (i < mDrawables.length) {
            child.setTag(i);
            child.setOnClickListener(this);
            child.getChildAt(0).setVisibility(preselect == i ? View.VISIBLE : View.GONE);
        } else {
            child.getChildAt(0).setVisibility(View.GONE);
            continue;
        }
        //Drawable selector = createSelector(mDrawables[i]);
        setBackgroundCompat(child, mDrawables[i]);
    }
    return dialog;
}
项目:DietDiaryApp    文件:BackupFragment.java   
@Override
public View onCreateView(@NonNull LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
    mGridLayout = (GridLayout) inflater.inflate(R.layout.fragment_backup_gridlayout, container, false);

    tvFromDatePicker = mGridLayout.findViewById(R.id.tvFromDatePicker);
    tvToDatePicker = mGridLayout.findViewById(R.id.tvToDatePicker);
    spFormats = mGridLayout.findViewById(R.id.spFormats);

    ResourcesHelper.setLeftCompoundDrawable(mGridLayout, R.id.tvFrom, R.drawable.calendar_today);
    ResourcesHelper.setLeftCompoundDrawable(mGridLayout, R.id.tvTo, R.drawable.calendar);
    ResourcesHelper.setLeftCompoundDrawable(mGridLayout, R.id.tvType, R.drawable.file);

    tvFromDatePicker.setOnClickListener(this);
    tvToDatePicker.setOnClickListener(this);

    tvFromDatePicker.setText(DateTimeHelper.convertLocalDateToString(mFromDate));
    tvToDatePicker.setText(DateTimeHelper.convertLocalDateToString(mToDate));

    if (null != savedInstanceState) {
        spFormats.setSelection(savedInstanceState.getInt(KEY_SELECTED_FORMAT_INT, 0));
    }

    if (null != mAsyncTask) {
        // To start progress dialog again.
        mAsyncTask.onPreExecute();
    }

    return mGridLayout;
}
项目:GridBuilder    文件:GridBuilder.java   
private GridBuilder(Context context, GridLayout gridLayout) {
    this.mContext = context;
    this.mGridLayout = gridLayout;
    this.mLayoutInflater = LayoutInflater.from(context);

    // 不使用默认margin
    this.mGridLayout.setUseDefaultMargins(false);
    this.mGridLayout.setAlignmentMode(GridLayout.ALIGN_BOUNDS);
    this.mGridLayout.setClipChildren(false);
    this.mGridLayout.setClipToPadding(false);
}
项目:GridBuilder    文件:GridViewHolder.java   
public GridViewHolder(GridLayout gridLayout) {
    mGridLayout = gridLayout;

    mAddedView = new LinkedBlockingQueue<>();
    mRemovedView = new LinkedBlockingQueue<>();

    init();
}
项目:authentication    文件:StudentSelectionActivity.java   
@Override
protected void onCreate(Bundle savedInstanceState) {
    Log.i(getClass().getName(), "onCreate");
    super.onCreate(savedInstanceState);

    setContentView(R.layout.activity_student_selection);

    LiteracyApplication literacyApplication = (LiteracyApplication) getApplication();
    studentDao = literacyApplication.getDaoSession().getStudentDao();

    studentSelectionGridLayout = (GridLayout) findViewById(R.id.studentSelectionGridLayout);
}
项目:AppPlus    文件:ColorChooseDialog.java   
private View getColorItemView(final Context context, int position, boolean isSelect) {
    int color = mColors[position];
    int widthImageCheckView = Utils.convertDensityPix(context, 24);
    int widthColorView = Utils.convertDensityPix(context, 56);
    int widthMargin = Utils.convertDensityPix(context, 4);

    ImageView imageView = new ImageView(context);
    imageView.setImageResource(R.drawable.ic_done_white_24dp);

    FrameLayout.LayoutParams ivParams = new FrameLayout.LayoutParams(widthImageCheckView, widthImageCheckView);
    ivParams.gravity = Gravity.CENTER;
    imageView.setLayoutParams(ivParams);
    imageView.setVisibility(isSelect ? View.VISIBLE : View.INVISIBLE);

    FrameLayout frameLayout = new FrameLayout(context);
    GridLayout.LayoutParams params = new GridLayout.LayoutParams(new FrameLayout.LayoutParams(widthColorView, widthColorView));
    params.setGravity(Gravity.CENTER);
    params.setMargins(widthMargin, widthMargin, widthMargin, widthMargin);
    frameLayout.setLayoutParams(params);

    setBackgroundSelector(frameLayout, color);

    frameLayout.addView(imageView);
    frameLayout.setOnClickListener(this);
    frameLayout.setTag(position);
    return frameLayout;
}
项目:Silence    文件:ColorPreference.java   
@Override
public Dialog onCreateDialog(Bundle savedInstanceState) {
  LayoutInflater layoutInflater = LayoutInflater.from(getActivity());
  View rootView = layoutInflater.inflate(R.layout.color_preference_items, null);

  mColorGrid = (GridLayout) rootView.findViewById(R.id.color_grid);
  mColorGrid.setColumnCount(mPreference.mNumColumns);
  repopulateItems();

  return new AlertDialog.Builder(getActivity())
      .setView(rootView)
      .create();
}
项目:honki_android    文件:MainActivity.java   
@Override
public void onWindowFocusChanged(boolean hasFocus) {
    super.onWindowFocusChanged(hasFocus);

    // GridLayout内のアイテムをレイアウトサイズに合わせてストレッチ
    final GridLayout gl = (GridLayout) findViewById(R.id.calcFrame);
    int childWidth = gl.getWidth() / gl.getColumnCount();
    int childHeight = gl.getHeight() / gl.getRowCount();
    for (int i = 0; i < gl.getChildCount(); i++) {
        gl.getChildAt(i).setMinimumWidth(childWidth);
        gl.getChildAt(i).setMinimumHeight(childHeight);
    }
}
项目:honki_android    文件:MainActivity.java   
@Override
public void onWindowFocusChanged(boolean hasFocus) {
    super.onWindowFocusChanged(hasFocus);

    // GridLayout内のアイテムをレイアウトサイズに合わせてストレッチ
    final GridLayout gl = (GridLayout) findViewById(R.id.calcFrame);
    int childWidth = gl.getWidth() / gl.getColumnCount();
    int childHeight = gl.getHeight() / gl.getRowCount();
    for (int i = 0; i < gl.getChildCount(); i++) {
        gl.getChildAt(i).setMinimumWidth(childWidth);
        gl.getChildAt(i).setMinimumHeight(childHeight);
    }
}
项目:365browser    文件:PaymentRequestSection.java   
public OptionRow(GridLayout parent, int rowIndex, int rowType,
        @Nullable PaymentOption item, boolean isSelected) {
    assert item != null || rowType != OPTION_ROW_TYPE_OPTION;
    boolean optionIconExists = item != null && item.getDrawableIcon() != null;
    boolean editIconExists = item != null && item.isEditable() && isSelected;
    boolean isEnabled = item != null && item.isValid();
    mRowType = rowType;
    mOption = item;
    mButton = createButton(parent, rowIndex, isSelected, isEnabled);
    mLabel = createLabel(parent, rowIndex, optionIconExists, editIconExists, isEnabled);
    mOptionIcon = optionIconExists
            ? createOptionIcon(parent, rowIndex, editIconExists) : null;
    mEditIcon = editIconExists ? createEditIcon(parent, rowIndex) : null;
}
项目:365browser    文件:PaymentRequestSection.java   
private View createEditIcon(GridLayout parent, int rowIndex) {
    View editorIcon = LayoutInflater.from(parent.getContext())
                              .inflate(R.layout.payment_option_edit_icon, null);

    // The icon floats to the right of everything.
    GridLayout.LayoutParams iconParams =
            new GridLayout.LayoutParams(GridLayout.spec(rowIndex, 1, GridLayout.CENTER),
                    GridLayout.spec(3, 1, GridLayout.CENTER));
    iconParams.topMargin = mVerticalMargin;
    parent.addView(editorIcon, iconParams);

    editorIcon.setOnClickListener(OptionSection.this);
    return editorIcon;
}
项目:365browser    文件:PaymentRequestSection.java   
@Override
protected void createMainSectionContent(LinearLayout mainSectionLayout) {
    Context context = mainSectionLayout.getContext();
    mCheckingProgress = createLoadingSpinner();

    mOptionLayout = new GridLayout(context);
    mOptionLayout.setColumnCount(4);
    mainSectionLayout.addView(mOptionLayout, new LinearLayout.LayoutParams(
            LayoutParams.MATCH_PARENT, LayoutParams.WRAP_CONTENT));
}
项目:shikimori    文件:Spoiler.java   
/**
 * Растягиваем изображения по ширине при открытии спойлера
 */
void openSpoiler(){
    spoilerBody.setVisibility(View.VISIBLE);
    if(openned)
        return;
    spoilerBody.post(new Runnable() {
        @Override
        public void run() {
            openned = true;
            int viewscount = spoilerBody.getChildCount();
            for (int i = 0; i < viewscount; i++) {
                // находим галлерею
                if(spoilerBody.getChildAt(i) instanceof GridLayout){
                    GridLayout grid = (GridLayout) spoilerBody.getChildAt(i);
                    int viewCount = grid.getChildCount();
                    // не более 3 на строку
                    int column = viewCount > 3 ? 3 : viewCount;
                    for (int g = 0; g < viewCount; g++) {
                        View v = grid.getChildAt(g);
                        GridLayout.LayoutParams itemParams = (GridLayout.LayoutParams) v.getLayoutParams();
                        itemParams.width = (grid.getWidth()/column) - itemParams.rightMargin - itemParams.leftMargin;
                        v.setLayoutParams(itemParams);
                    }
                }
            }
        }
    });
}
项目:shikimori    文件:CustomGridlayout.java   
private void buildViews() {
        post(new Runnable() {
            @Override
            public void run() {
                if(checkWifth == getWidth())
                    return;
                checkWifth = getWidth();
                // если 1 элемент то ничего не делаем
                int viewCount = getChildCount();
                int column = viewCount > 3 ? 3 : viewCount;
                int gridSize = getWidth()/* == 0 ? screensize.x : getWidth()*/;
                gridSize -= (getPaddingLeft() - getPaddingRight());
                int parentPadding = ((ViewGroup) getParent()).getPaddingLeft();
                gridSize -= (parentPadding*2);
//                Point screen = hs.getScreenSize((Activity) getContext());
//                gridSize -= (screen.x - gridSize);

                for (int i = 0; i < viewCount; i++) {
                    View v = getChildAt(i);
                    GridLayout.LayoutParams itemParams = (GridLayout.LayoutParams) v.getLayoutParams();

                    gridSize -= (itemParams.rightMargin - itemParams.leftMargin);
                    itemParams.width = (gridSize / column);
                    v.setLayoutParams(itemParams);
                }
            }
        });
    }
项目:commcare-android    文件:EntityViewTile.java   
private GridLayout.LayoutParams getLayoutParamsForField(GridCoordinate coordinateData) {
    Spec columnSpec = GridLayout.spec(coordinateData.getX(), coordinateData.getWidth());
    Spec rowSpec = GridLayout.spec(coordinateData.getY(), coordinateData.getHeight());

    GridLayout.LayoutParams gridParams = new GridLayout.LayoutParams(rowSpec, columnSpec);
    gridParams.width = (int)Math.ceil(cellWidth * coordinateData.getWidth());
    gridParams.height = (int)Math.ceil(cellHeight * coordinateData.getHeight());

    return gridParams;
}
项目:calendula    文件:NumberPadView.java   
private void initView() {
    // inflate numpad
    numpadLayout = (GridLayout) inflate(getContext(), R.layout.view_num_pad, null);
    addView(numpadLayout);
    // set icon for the delete button
    final AppCompatImageButton deleteButton = (AppCompatImageButton) numpadLayout.findViewById(R.id.numpad_delete_btn);
    final IconicsDrawable deleteIcon = IconUtils.icon(getContext(), GoogleMaterial.Icon.gmd_tag_backspace, R.color.white, 20);
    deleteButton.setImageDrawable(deleteIcon);
    // add listeners
    for (int i = 0; i < numpadLayout.getChildCount(); i++) {
        numpadLayout.getChildAt(i).setOnClickListener(new NumpadButtonListener());
    }
}
项目:mobile-store    文件:AppDetailsRecyclerViewAdapter.java   
DonateViewHolder(View view) {
    super(view);
    donateHeading = (TextView) view.findViewById(R.id.donate_header);
    donationOptionsLayout = (GridLayout) view.findViewById(R.id.donation_options);
}
项目:BlindsEffect    文件:NewEffect.java   
public NewEffect(GridLayout container, @DrawableRes int oldImage, @DrawableRes int newImage) {
    this.mContainer = container;
    this.mOldImage = oldImage;
    this.mNewImage = newImage;
    setContainer(DEFAULT_COLUMN_COUNT, DEFAULT_ROW_COUNT);
}
项目:BlindsEffect    文件:NewEffect.java   
public NewEffect(GridLayout container, View oldView, View newView) {
    this.mContainer = container;
    this.mOldView = oldView;
    this.mNewView = newView;
    setContainer(DEFAULT_COLUMN_COUNT, DEFAULT_ROW_COUNT);
}
项目:truth-android    文件:GridLayoutSubject.java   
protected GridLayoutSubject(FailureStrategy failureStrategy, GridLayout subject) {
  super(failureStrategy, subject);
}