當前位置: 首頁>>代碼示例>>Java>>正文


Java GridLayout類代碼示例

本文整理匯總了Java中android.support.v7.widget.GridLayout的典型用法代碼示例。如果您正苦於以下問題:Java GridLayout類的具體用法?Java GridLayout怎麽用?Java GridLayout使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。


GridLayout類屬於android.support.v7.widget包,在下文中一共展示了GridLayout類的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: run

import android.support.v7.widget.GridLayout; //導入依賴的package包/類
@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;
    }
}
 
開發者ID:philliphsu,項目名稱:NumberPadTimePicker,代碼行數:25,代碼來源:NumberPadTimePickerBottomSheetComponent.java

示例2: populateFavorites

import android.support.v7.widget.GridLayout; //導入依賴的package包/類
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);
        }
    }
}
 
開發者ID:andryr,項目名稱:Harmony-Music-Player,代碼行數:22,代碼來源:HomeFragment.java

示例3: SuggestionViewHolder

import android.support.v7.widget.GridLayout; //導入依賴的package包/類
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);
    }
}
 
開發者ID:GavinAndre,項目名稱:MaterialWeather,代碼行數:23,代碼來源:MyAdapter.java

示例4: generateColorBlocks

import android.support.v7.widget.GridLayout; //導入依賴的package包/類
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);
    }
}
 
開發者ID:emugabi,項目名稱:colorblocks,代碼行數:26,代碼來源:ColorPickerFragment.java

示例5: setData

import android.support.v7.widget.GridLayout; //導入依賴的package包/類
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);
        }
    }
}
 
開發者ID:evant,項目名稱:PokeMVVM,代碼行數:20,代碼來源:TableCardLayout.java

示例6: onPostExecute

import android.support.v7.widget.GridLayout; //導入依賴的package包/類
@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);
    }
}
 
開發者ID:enihsyou,項目名稱:PackageTracker,代碼行數:27,代碼來源:FetchTimeTask.java

示例7: addReflectionImageView

import android.support.v7.widget.GridLayout; //導入依賴的package包/類
/**
 * 將倒影布局添加到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);
}
 
開發者ID:Eason90,項目名稱:GridBuilder,代碼行數:22,代碼來源:GridBuilder.java

示例8: onCreateDialog

import android.support.v7.widget.GridLayout; //導入依賴的package包/類
@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;
}
 
開發者ID:maoruibin,項目名稱:AppPlus,代碼行數:19,代碼來源:ColorChooseDialog.java

示例9: createMainSectionContent

import android.support.v7.widget.GridLayout; //導入依賴的package包/類
@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;
}
 
開發者ID:mogoweb,項目名稱:365browser,代碼行數:24,代碼來源:PaymentRequestSection.java

示例10: createOptionIcon

import android.support.v7.widget.GridLayout; //導入依賴的package包/類
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;
}
 
開發者ID:mogoweb,項目名稱:365browser,代碼行數:24,代碼來源:PaymentRequestSection.java

示例11: addBuffersToView

import android.support.v7.widget.GridLayout; //導入依賴的package包/類
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);
    }
}
 
開發者ID:dimagi,項目名稱:commcare-android,代碼行數:19,代碼來源:EntityViewTile.java

示例12: addFieldView

import android.support.v7.widget.GridLayout; //導入依賴的package包/類
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);
}
 
開發者ID:dimagi,項目名稱:commcare-android,代碼行數:22,代碼來源:EntityViewTile.java

示例13: fillSensorsTextViews

import android.support.v7.widget.GridLayout; //導入依賴的package包/類
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);
        }
    }
}
 
開發者ID:nextgis,項目名稱:nextgislogger,代碼行數:19,代碼來源:InfoSensorsFragment.java

示例14: updateView

import android.support.v7.widget.GridLayout; //導入依賴的package包/類
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);
            }
        }
    });
}
 
開發者ID:FreeSunny,項目名稱:Amazing,代碼行數:31,代碼來源:Sudoku.java

示例15: onCreateDialog

import android.support.v7.widget.GridLayout; //導入依賴的package包/類
@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();
}
 
開發者ID:XecureIT,項目名稱:PeSanKita-android,代碼行數:14,代碼來源:ColorPreference.java


注:本文中的android.support.v7.widget.GridLayout類示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。