本文整理匯總了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;
}
}
示例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);
}
}
});
}
示例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);
}