本文整理匯總了Java中android.widget.GridLayout.LayoutParams方法的典型用法代碼示例。如果您正苦於以下問題:Java GridLayout.LayoutParams方法的具體用法?Java GridLayout.LayoutParams怎麽用?Java GridLayout.LayoutParams使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類android.widget.GridLayout
的用法示例。
在下文中一共展示了GridLayout.LayoutParams方法的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: createOptionIcon
import android.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);
optionIcon.setBackgroundResource(R.drawable.payments_ui_logo_bg);
optionIcon.setImageDrawable(mOption.getDrawableIcon());
optionIcon.setMaxWidth(mIconMaxWidth);
// 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));
iconParams.topMargin = mVerticalMargin;
parent.addView(optionIcon, iconParams);
optionIcon.setOnClickListener(OptionSection.this);
return optionIcon;
}
示例2: makeColorPresetButton
import android.widget.GridLayout; //導入方法依賴的package包/類
private void makeColorPresetButton(int color) {
FrameLayout outframe = new FrameLayout(getContext());
outframe.setBackgroundColor(Color.BLACK);
outframe.setPadding(6,6,6,6);
FrameLayout frame = new FrameLayout(getContext());
//frame.setBackgroundColor(Color.BLACK);
frame.setBackgroundResource(R.drawable.transparentgrid);
TextView c = new TextView(getContext());
c.setText(" ");
c.setTextSize(22);
c.setBackgroundColor(color);
// if (color==Color.TRANSPARENT) {
// c.setBackgroundResource(R.drawable.transparentgrid);
// }
c.setTag(color);
c.setClickable(true);
c.setOnClickListener(setColorListener);
frame.addView(c);
GridLayout.LayoutParams lp = new GridLayout.LayoutParams();
lp.setMargins(24, 16, 24, 16);
outframe.setPadding(6,6,6,6);
outframe.addView(frame);
colorPresets.addView(outframe, lp);
}
示例3: ColorGridView
import android.widget.GridLayout; //導入方法依賴的package包/類
public ColorGridView(@NonNull final Context context, @Nullable AttributeSet attrs, @AttrRes int defStyleAttr) {
super(context, attrs, defStyleAttr);
setWillNotDraw(false);
setRowCount(ROWS);
setColumnCount(COLS);
for (int row = 0; row < ROWS; row++) {
Spec rowSpec = spec(row);
for (int col = 0; col < COLS; col++) {
Spec colSpec = spec(col);
LayoutParams params = new GridLayout.LayoutParams(rowSpec, colSpec);
params.width = 150;
params.height = 150;
View view = createView(context);
addView(view, params);
}
}
}
示例4: setUpClsTitle
import android.widget.GridLayout; //導入方法依賴的package包/類
private void setUpClsTitle(){
for (int i=0; i<TITLE_DATA.length; ++i){
String content = TITLE_DATA[i];
GridLayout.LayoutParams params = new GridLayout.LayoutParams();
//第一列的時候
if (i == 0){
params.width = mTableDistance;
}
else {
//添加分割線
View divider = getLayoutInflater().inflate(R.layout.grid_title_form,mGlClsTitle,false);
mGlClsTitle.addView(divider);
params.width = mTableDistance * 2;
}
params.height = GridLayout.LayoutParams.MATCH_PARENT;
TextView textView = new TextView(this);
textView.setTextColor(getResources().getColor(R.color.blue));
textView.setText(content);
textView.setGravity(Gravity.CENTER);
mGlClsTitle.addView(textView,params);
}
}
示例5: generateColoredButtons
import android.widget.GridLayout; //導入方法依賴的package包/類
private void generateColoredButtons() {
for (int i=0; i<ROWS; i++) {
for (int j=0; j<COLUMNS; j++) {
int count = COLUMNS * i + j;
if (count > Constants.COLORS.length - 1) {
return;
}
Button b = new Button(this);
b.setBackgroundResource(R.drawable.round_button);
b.setBackgroundColor(getResources().getColor(Constants.COLORS[count]));
b.setTag(count);
b.setOnClickListener(this);
GridLayout.LayoutParams params = new GridLayout.LayoutParams();
params.height = GridLayout.LayoutParams.WRAP_CONTENT;
params.width = GridLayout.LayoutParams.WRAP_CONTENT;
params.rowSpec = GridLayout.spec(i);
params.columnSpec = GridLayout.spec(j);
b.setLayoutParams(params);
mGrid.addView(b);
}
}
}
示例6: removeAttribute
import android.widget.GridLayout; //導入方法依賴的package包/類
@Override
public void removeAttribute(View view, AttrLayoutContext attrCtx)
{
ViewGroup.LayoutParams params = view.getLayoutParams();
if (params instanceof GridLayout.LayoutParams)
{
// No hacemos nada, no puede ser cambiado "post-creación"
}
else if (params instanceof TableRow.LayoutParams)
{
((TableRow.LayoutParams)params).column = -1;
PendingViewPostCreateProcess.onChangedLayoutParams(view);
}
}
示例7: addTableHeader
import android.widget.GridLayout; //導入方法依賴的package包/類
private GridLayout addTableHeader( String... headers ) {
GridLayout gridLayout = new GridLayout( getContext() );
gridLayout.setBackgroundResource( R.color.grey_faint );
int rowNum = 0;
int columnNum = 0;
for ( String header : headers ) {
RobotoTextView headerText = new RobotoTextView( getContext() );
headerText.setTextAppearance( getContext(), R.style.CardKey );
headerText.setText( header );
Spec rowspecs = GridLayout.spec( rowNum, 1 );
Spec colspecs = GridLayout.spec( columnNum, 1 );
GridLayout.LayoutParams params = new GridLayout.LayoutParams( rowspecs, colspecs );
params.setGravity( Gravity.CENTER_HORIZONTAL );
params.setMargins( getContext().getResources().getDimensionPixelSize( R.dimen.column_padding ), 0, getContext().getResources().getDimensionPixelSize( R.dimen.column_padding ), 0 );
gridLayout.addView( headerText, params );
columnNum++;
}
return gridLayout;
}
示例8: addTableRow
import android.widget.GridLayout; //導入方法依賴的package包/類
private void addTableRow( GridLayout gridLayout, String... columns ) {
int rowNum = gridLayout.getRowCount();
int columnNum = 0;
for ( String column : columns ) {
RobotoTextView columnText = new RobotoTextView( getContext() );
columnText.setTextAppearance( getContext(), R.style.CardValue );
columnText.setText( column );
Spec rowspecs = GridLayout.spec( rowNum, 1 );
Spec colspecs = GridLayout.spec( columnNum, 1 );
GridLayout.LayoutParams params = new GridLayout.LayoutParams( rowspecs, colspecs );
params.setGravity( Gravity.CENTER_HORIZONTAL );
gridLayout.addView( columnText, params );
columnNum++;
}
}
示例9: onLayoutChange
import android.widget.GridLayout; //導入方法依賴的package包/類
@Override
public void onLayoutChange(View v, int left, int top, int right, int bottom,
int oldLeft, int oldTop, int oldRight, int oldBottom) {
if (right - left == oldRight - oldLeft) {
return;
}
int cellWidth = mGrid.getWidth() / columnCount;
for (int i = 0; i < mGrid.getChildCount(); ++i) {
View cell = mGrid.getChildAt(i);
GridLayout.LayoutParams lp = (GridLayout.LayoutParams) cell.getLayoutParams();
lp.width = cellWidth;
cell.setLayoutParams(lp);
}
}
示例10: createEditIcon
import android.widget.GridLayout; //導入方法依賴的package包/類
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));
iconParams.topMargin = mVerticalMargin;
parent.addView(editorIcon, iconParams);
editorIcon.setOnClickListener(OptionSection.this);
return editorIcon;
}
示例11: addAppToIconSheet
import android.widget.GridLayout; //導入方法依賴的package包/類
private void addAppToIconSheet(GridLayout iconSheet, AppLauncher app, int pos, boolean reuse) {
if (app != null) {
try {
if ((app.isWidget() && isAppInstalled(app.getPackageName())) || mLaunchApp.isValidActivity(app)) {
ViewGroup item = getLauncherView(app, false, reuse);
if (item != null) {
if (!app.iconLoaded()) {
app.loadAppIconAsync(this, mPackageMan);
}
ViewGroup parent = (ViewGroup) item.getParent();
if (parent != null) parent.removeView(item);
GridLayout.LayoutParams lp = getAppLauncherLayoutParams(iconSheet, app);
iconSheet.addView(item, pos, lp);
return;
}
} else {
db().deleteApp(app.getComponentName());
Log.d(TAG, "removed " + app.getPackageName() + " " + app.getActivityName() + ":activity not valid.");
}
} catch (Exception e) {
Log.e(TAG, "exception adding icon to sheet", e);
Toast.makeText(this,"Couldn't place icon: " + e.getMessage(), Toast.LENGTH_LONG).show();
}
} else {
Log.d(TAG, "Not showing recent: Null.");
}
}
示例12: createAbout
import android.widget.GridLayout; //導入方法依賴的package包/類
private void createAbout() {
innerWrapperLayout.setTranslationY(-30);
FrameLayout.LayoutParams layoutParams = (FrameLayout.LayoutParams) innerWrapperLayout.getLayoutParams();
layoutParams.gravity = Gravity.BOTTOM | Gravity.CENTER_HORIZONTAL;
/* -------------- */
/* New components */
/* This inner wrapper is needed for gravity to work correctly */
FrameLayout aboutInnerWrapperLayout = new FrameLayout(activity);
aboutInnerWrapperLayout.setLayoutParams(new FrameLayout.LayoutParams(ViewGroup.LayoutParams.WRAP_CONTENT, ViewGroup.LayoutParams.WRAP_CONTENT, Gravity.CENTER));
aboutInnerWrapperLayout.setTranslationY(-60);
/* All information should be in this gridLayout */
GridLayout aboutLayout = new GridLayout(activity);
GridLayout.LayoutParams aboutLayoutParams = new GridLayout.LayoutParams();
aboutLayoutParams.setGravity(Gravity.CENTER);
aboutLayout.setLayoutParams(aboutLayoutParams);
/* Scroll view in case the content is too big */
ScrollView scrollView = new ScrollView(activity);
scrollView.setLayoutParams(new ScrollView.LayoutParams(ViewGroup.LayoutParams.WRAP_CONTENT, ViewGroup.LayoutParams.WRAP_CONTENT));
scrollView.setBackgroundColor(Misc.getColor(activity, R.color.colorPrimary));
scrollView.setPadding(0, 120, 0, 120);
/* Format with HTML. This is way easier for specific tasks. Warning, colors in the WebView are hardcoded. */
WebView aboutText = new WebView(activity);
aboutText.setBackgroundColor(Color.TRANSPARENT);
aboutText.loadData(activity.getString(R.string.about), "text/html", "utf-8");
/* Back button */
TextView backButton = new TextView(activity);
backButton.setTextColor(Misc.getColor(activity, R.color.colorAccent));
backButton.setText("back");
backButton.setPadding(0, 0, 0, 70);
backButton.setGravity(Gravity.CENTER);
backButton.setTextSize(TypedValue.COMPLEX_UNIT_SP, 36);
backButton.setTypeface(Typeface.create("sans-serif-thin", Typeface.NORMAL));
backButton.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
setCallback(0);
}
});
/* -------------------------- */
/* Bundle everything together */
aboutLayout.addView(backButton, new GridLayout.LayoutParams(GridLayout.spec(0, GridLayout.CENTER), GridLayout.spec(0, GridLayout.CENTER)));
aboutLayout.addView(aboutText, new GridLayout.LayoutParams(GridLayout.spec(1, GridLayout.CENTER), GridLayout.spec(0, GridLayout.CENTER)));
scrollView.addView(aboutLayout);
aboutInnerWrapperLayout.addView(scrollView);
outerWrapperLayout.addView(aboutInnerWrapperLayout);
}
示例13: removeAttribute
import android.widget.GridLayout; //導入方法依賴的package包/類
@Override
public void removeAttribute(View view, AttrLayoutContext attrCtx)
{
ViewGroup.LayoutParams params = view.getLayoutParams();
if (params instanceof LinearLayout.LayoutParams)
((LinearLayout.LayoutParams)params).gravity = Gravity.LEFT;
else if (params instanceof FrameLayout.LayoutParams)
((FrameLayout.LayoutParams)params).gravity = Gravity.LEFT;
else if (params instanceof GridLayout.LayoutParams)
((GridLayout.LayoutParams)params).setGravity(Gravity.LEFT); // La doc habla también de un BASELINE pero no lo encuentro como Gravity
PendingViewPostCreateProcess.onChangedLayoutParams(view);
}
示例14: setAttributes
import android.widget.GridLayout; //導入方法依賴的package包/類
public void setAttributes(View view)
{
GridLayout viewParent = (GridLayout)view.getParent();
GridLayout.Spec spec = GridLayout.spec(getStart(), getSpan(), getAlignment(viewParent, layout_gravity, isHorizontal()));
GridLayout.LayoutParams params = (GridLayout.LayoutParams)view.getLayoutParams();
setSpec(params,spec);
}
示例15: initGridLayout
import android.widget.GridLayout; //導入方法依賴的package包/類
private void initGridLayout() {
gridLayout.removeAllViews();
int total = 12;
int column = 5;
int row = total / column;
gridLayout.setColumnCount(column);
gridLayout.setRowCount(row + 1);
for(int i =0, c = 0, r = 0; i < total; i++, c++)
{
if(c == column)
{
c = 0;
r++;
}
ImageView oImageView = new ImageView(this);
oImageView.setImageResource(R.mipmap.ic_launcher);
GridLayout.LayoutParams param =new GridLayout.LayoutParams();
param.height = GridLayout.LayoutParams.WRAP_CONTENT;
param.width = GridLayout.LayoutParams.WRAP_CONTENT;
param.rightMargin = 5;
param.topMargin = 5;
param.setGravity(Gravity.CENTER);
param.columnSpec = GridLayout.spec(c);
param.rowSpec = GridLayout.spec(r);
oImageView.setLayoutParams (param);
gridLayout.addView(oImageView);
}
}