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


Java GridLayout.Spec方法代碼示例

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


在下文中一共展示了GridLayout.Spec方法的3個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的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: 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

示例3: makeKeyboard

import android.support.v7.widget.GridLayout; //導入方法依賴的package包/類
private void makeKeyboard()
{
    DisplayMetrics display = getResources().getDisplayMetrics();

    final int BUTTON_HEIGHT_DP = 42;
    final int BUTTON_WIDTH_DP = 30;
    final int BUTTON_ROW_GAP_DP = 10;

    final int BUTTON_WIDTH = (int) TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_DIP, BUTTON_WIDTH_DP, display);

    final int pxWidth = Math.min(BUTTON_WIDTH, display.widthPixels / TRAINER_KEYBOARD_LINE_LENGTH); // no padding anywhere
    final int pxHeight = (int) TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_DIP, BUTTON_HEIGHT_DP, display);

    for (int r = 0; r < TRAINER_KEYBOARD_LINES_NUM; r++)
    {
        GridLayout.Spec rowSpec = GridLayout.spec(r, 1.0f);
        for (int c = 0; c < TRAINER_KEYBOARD_LINE_LENGTH; c++)
        {
            char cap = TRAINER_KEYBOARD_LINES[r].charAt(c);
            if (Character.isLetter(cap))
            {
                GridLayout.Spec colSpec = GridLayout.spec(c, 1.0f);

                GridLayout.LayoutParams params = new GridLayout.LayoutParams(rowSpec, colSpec);
                params.bottomMargin = (r < TRAINER_KEYBOARD_LINES_NUM - 1) ? BUTTON_ROW_GAP_DP : BUTTON_ROW_GAP_DP / 2;

                Button k = new Button(this, null, android.R.attr.buttonStyle);
                k.setMinHeight(pxHeight);
                k.setMinWidth(pxWidth);
                k.setMinimumHeight(pxHeight);
                k.setMinimumWidth(pxWidth);
                k.setPadding(0, 0, 0, 0);
                k.setOnClickListener(mKeyBoardListener);
                k.setText(String.valueOf(cap));
                k.setTypeface(k.getTypeface(), 1); // bold
                k.setTextSize(22); // sp
                //k.setGravity(Gravity.CENTER);
                k.setAllCaps(false);

                mKeyboard.addView(k, params);
                mKeys.add(k);
            }
        }
    }
    mEnter.setVisibility(View.GONE);
    mEnter.setMinHeight(pxHeight);
    mEnter.setMinimumHeight(pxHeight);
}
 
開發者ID:sergburn,項目名稱:firu,代碼行數:49,代碼來源:TrainerActivity.java


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