Java Code Examples for android.widget.TableRow#LayoutParams

The following examples show how to use android.widget.TableRow#LayoutParams . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: BodyElementTableRow.java    From RedReader with GNU General Public License v3.0 6 votes vote down vote up
@Override
public View generateView(
		@NonNull final AppCompatActivity activity,
		@Nullable final Integer textColor,
		@Nullable final Float textSize,
		final boolean showLinkButtons) {

	final TableRow result = new TableRow(activity);

	for(final BodyElement element : mElements) {

		final View view = element.generateView(activity, textColor, textSize, showLinkButtons);
		result.addView(view);

		final TableRow.LayoutParams layoutParams = (TableRow.LayoutParams)view.getLayoutParams();

		layoutParams.width = ViewGroup.LayoutParams.WRAP_CONTENT;
		layoutParams.height = ViewGroup.LayoutParams.WRAP_CONTENT;

		view.setLayoutParams(layoutParams);
	}

	return result;
}
 
Example 2
Source File: ViewUtil.java    From appinventor-extensions with Apache License 2.0 6 votes vote down vote up
public static void setChildWidthForTableLayout(View view, int width) {
  Object layoutParams = view.getLayoutParams();
  if (layoutParams instanceof TableRow.LayoutParams) {
    TableRow.LayoutParams tableLayoutParams = (TableRow.LayoutParams) layoutParams;
    switch (width) {
      case Component.LENGTH_PREFERRED:
        tableLayoutParams.width = TableRow.LayoutParams.WRAP_CONTENT;
        break;
      case Component.LENGTH_FILL_PARENT:
        tableLayoutParams.width = TableRow.LayoutParams.FILL_PARENT;
        break;
      default:
        tableLayoutParams.width = calculatePixels(view, width);
        break;
    }
    view.requestLayout();
  } else {
    Log.e("ViewUtil", "The view does not have table layout parameters");
  }
}
 
Example 3
Source File: ColorPickerPalette.java    From privacy-friendly-ludo with GNU General Public License v3.0 5 votes vote down vote up
/**
 * Creates a color swatch.
 */
private ColorPickerSwatch createColorSwatch(int color, int selectedColor) {
    ColorPickerSwatch view = new ColorPickerSwatch(getContext(), color,
            color == selectedColor, mOnColorSelectedListener);
    TableRow.LayoutParams params = new TableRow.LayoutParams(mSwatchLength, mSwatchLength);
    params.setMargins(mMarginSize, mMarginSize, mMarginSize, mMarginSize);
    view.setLayoutParams(params);
    return view;
}
 
Example 4
Source File: ColorPickerPalette.java    From Augendiagnose with GNU General Public License v2.0 5 votes vote down vote up
/**
 * Creates a color swatch.
 *
 * @param color         The color of the swatch.
 * @param selectedColor The selected color.
 * @return the created color swatch.
 */
@NonNull
private ColorPickerSwatch createColorSwatch(final int color, final int selectedColor) {
	ColorPickerSwatch view = new ColorPickerSwatch(getContext(), color,
			color == selectedColor, mOnColorSelectedListener);
	TableRow.LayoutParams params = new TableRow.LayoutParams(mSwatchLength, mSwatchLength);
	params.setMargins(mMarginSize, mMarginSize, mMarginSize, mMarginSize);
	view.setLayoutParams(params);
	return view;
}
 
Example 5
Source File: template_automatic_ll.java    From KickAssSlidingMenu with Apache License 2.0 5 votes vote down vote up
protected TableRow.LayoutParams findBoxWidth(final bind mbind, int size) {
    if (mbind.size == bind.HALF) {
        return new TableRow.LayoutParams(size == bind.HALF ? row_height : screen_size.x, row_height);
    } else {
        return new TableRow.LayoutParams(size == bind.HALF ? row_height : screen_size.x, calculateRowHeightBy2());
    }
}
 
Example 6
Source File: ColorPickerPalette.java    From ColorPicker with Apache License 2.0 5 votes vote down vote up
/**
 * Creates a color swatch.
 */
private ColorPickerSwatch createColorSwatch(int color, int selectedColor, int width,
        int strokeColor) {
    ColorPickerSwatch view = new ColorPickerSwatch(getContext(), color,
            color == selectedColor, width, strokeColor, mOnColorSelectedListener);
    TableRow.LayoutParams params = new TableRow.LayoutParams(mSwatchLength, mSwatchLength);
    params.setMargins(mMarginSize, mMarginSize, mMarginSize, mMarginSize);
    view.setLayoutParams(params);
    return view;
}
 
Example 7
Source File: PulldownViewActivity.java    From PullScrollView with Apache License 2.0 5 votes vote down vote up
public void showTable() {
    TableRow.LayoutParams layoutParams = new TableRow.LayoutParams(
            TableRow.LayoutParams.MATCH_PARENT,
            TableRow.LayoutParams.WRAP_CONTENT);
    layoutParams.gravity = Gravity.CENTER;
    layoutParams.leftMargin = 30;
    layoutParams.bottomMargin = 10;
    layoutParams.topMargin = 10;

    for (int i = 0; i < 30; i++) {
        TableRow tableRow = new TableRow(this);
        TextView textView = new TextView(this);
        textView.setText("Test pull down scroll view " + i);
        textView.setTextSize(20);
        textView.setPadding(15, 15, 15, 15);

        tableRow.addView(textView, layoutParams);
        if (i % 2 != 0) {
            tableRow.setBackgroundColor(Color.LTGRAY);
        } else {
            tableRow.setBackgroundColor(Color.WHITE);
        }

        final int n = i;
        tableRow.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                Toast.makeText(PulldownViewActivity.this, "Click item " + n, Toast.LENGTH_SHORT).show();
            }
        });

        mMainLayout.addView(tableRow);
    }
}
 
Example 8
Source File: PulldownViewActivity.java    From BigApp_Discuz_Android with Apache License 2.0 5 votes vote down vote up
public void showTable() {
    TableRow.LayoutParams layoutParams = new TableRow.LayoutParams(
            TableRow.LayoutParams.MATCH_PARENT,
            TableRow.LayoutParams.WRAP_CONTENT);
    layoutParams.gravity = Gravity.CENTER;
    layoutParams.leftMargin = 30;
    layoutParams.bottomMargin = 10;
    layoutParams.topMargin = 10;

    for (int i = 0; i < 30; i++) {
        TableRow tableRow = new TableRow(this);
        TextView textView = new TextView(this);
        textView.setText("Test pull down scroll view " + i);
        textView.setTextSize(20);
        textView.setPadding(15, 15, 15, 15);

        tableRow.addView(textView, layoutParams);
        if (i % 2 != 0) {
            tableRow.setBackgroundColor(Color.LTGRAY);
        } else {
            tableRow.setBackgroundColor(Color.WHITE);
        }

        final int n = i;
        tableRow.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                Toast.makeText(PulldownViewActivity.this, "Click item " + n, Toast.LENGTH_SHORT).show();
            }
        });

        mMainLayout.addView(tableRow);
    }
}
 
Example 9
Source File: StretchViewActivity.java    From PullScrollView with Apache License 2.0 5 votes vote down vote up
public void showTable() {
    TableRow.LayoutParams layoutParams = new TableRow.LayoutParams(
            TableRow.LayoutParams.MATCH_PARENT,
            TableRow.LayoutParams.WRAP_CONTENT);
    layoutParams.gravity = Gravity.CENTER;
    layoutParams.leftMargin = 30;
    layoutParams.bottomMargin = 10;
    layoutParams.topMargin = 10;

    for (int i = 0; i < 40; i++) {
        TableRow tableRow = new TableRow(this);
        TextView textView = new TextView(this);
        textView.setText("Test stretch scroll view " + i);
        textView.setTextSize(20);
        textView.setPadding(15, 15, 15, 15);

        tableRow.addView(textView, layoutParams);
        if (i % 2 != 0) {
            tableRow.setBackgroundColor(Color.LTGRAY);
        } else {
            tableRow.setBackgroundColor(Color.WHITE);
        }

        final int n = i;
        tableRow.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                Toast.makeText(StretchViewActivity.this, "Click item " + n, Toast.LENGTH_SHORT).show();
            }
        });

        mMainLayout.addView(tableRow);
    }
}
 
Example 10
Source File: ColorPickerPalette.java    From ColorPicker with Apache License 2.0 5 votes vote down vote up
/**
 * Creates a blank space to fill the row.
 */
private ImageView createBlankSpace() {
    ImageView view = new ImageView(getContext());
    TableRow.LayoutParams params = new TableRow.LayoutParams(mSwatchLength, mSwatchLength);
    params.setMargins(mMarginSize, mMarginSize, mMarginSize, mMarginSize);
    view.setLayoutParams(params);
    return view;
}
 
Example 11
Source File: StretchViewActivity.java    From UltimateAndroid with Apache License 2.0 5 votes vote down vote up
public void showTable() {
    TableRow.LayoutParams layoutParams = new TableRow.LayoutParams(
            TableRow.LayoutParams.MATCH_PARENT,
            TableRow.LayoutParams.WRAP_CONTENT);
    layoutParams.gravity = Gravity.CENTER;
    layoutParams.leftMargin = 30;
    layoutParams.bottomMargin = 10;
    layoutParams.topMargin = 10;

    for (int i = 0; i < 40; i++) {
        TableRow tableRow = new TableRow(this);
        TextView textView = new TextView(this);
        textView.setText("Test stretch scroll view " + i);
        textView.setTextSize(20);
        textView.setPadding(15, 15, 15, 15);

        tableRow.addView(textView, layoutParams);
        if (i % 2 != 0) {
            tableRow.setBackgroundColor(Color.LTGRAY);
        } else {
            tableRow.setBackgroundColor(Color.WHITE);
        }

        final int n = i;
        tableRow.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                Toast.makeText(StretchViewActivity.this, "Click item " + n, Toast.LENGTH_SHORT).show();
            }
        });

        mMainLayout.addView(tableRow);
    }
}
 
Example 12
Source File: ColorPickerPalette.java    From android-kernel-tweaker with GNU General Public License v3.0 5 votes vote down vote up
/**
 * Creates a blank space to fill the row.
 */
private ImageView createBlankSpace() {
    ImageView view = new ImageView(getContext());
    TableRow.LayoutParams params = new TableRow.LayoutParams(mSwatchLength, mSwatchLength);
    params.setMargins(mMarginSize, mMarginSize, mMarginSize, mMarginSize);
    view.setLayoutParams(params);
    return view;
}
 
Example 13
Source File: ColorPickerPalette.java    From KAM with GNU General Public License v3.0 5 votes vote down vote up
/**
 * Creates a blank space to fill the row.
 */
private ImageView createBlankSpace() {
    ImageView view = new ImageView(getContext());
    TableRow.LayoutParams params = new TableRow.LayoutParams(mSwatchLength, mSwatchLength);
    params.setMargins(mMarginSize, mMarginSize, mMarginSize, mMarginSize);
    view.setLayoutParams(params);
    return view;
}
 
Example 14
Source File: StretchViewActivity.java    From UltimateAndroid with Apache License 2.0 5 votes vote down vote up
public void showTable() {
    TableRow.LayoutParams layoutParams = new TableRow.LayoutParams(
            TableRow.LayoutParams.MATCH_PARENT,
            TableRow.LayoutParams.WRAP_CONTENT);
    layoutParams.gravity = Gravity.CENTER;
    layoutParams.leftMargin = 30;
    layoutParams.bottomMargin = 10;
    layoutParams.topMargin = 10;

    for (int i = 0; i < 40; i++) {
        TableRow tableRow = new TableRow(this);
        TextView textView = new TextView(this);
        textView.setText("Test stretch scroll view " + i);
        textView.setTextSize(20);
        textView.setPadding(15, 15, 15, 15);

        tableRow.addView(textView, layoutParams);
        if (i % 2 != 0) {
            tableRow.setBackgroundColor(Color.LTGRAY);
        } else {
            tableRow.setBackgroundColor(Color.WHITE);
        }

        final int n = i;
        tableRow.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                Toast.makeText(StretchViewActivity.this, "Click item " + n, Toast.LENGTH_SHORT).show();
            }
        });

        mMainLayout.addView(tableRow);
    }
}
 
Example 15
Source File: SumsManager.java    From fingen with Apache License 2.0 5 votes vote down vote up
private static void setTextViewParams(TextView textView, int color, String text, boolean typeFaceLight, float textSize, int gravity) {
        textView.setTextSize(TypedValue.COMPLEX_UNIT_DIP, textSize);
        textView.setGravity(gravity);
        textView.setTextColor(color);
        textView.setText(text);
        if (typeFaceLight) {
            textView.setTypeface(Typeface.create("sans-serif-light", Typeface.NORMAL));
        } else {
            textView.setTypeface(Typeface.create("sans-serif-medium", Typeface.NORMAL));
        }
        TableRow.LayoutParams params = new TableRow.LayoutParams(TableRow.LayoutParams.MATCH_PARENT, TableRow.LayoutParams.WRAP_CONTENT);
        params.bottomMargin = 4;
//        params.setMarginStart(16);
        textView.setLayoutParams(params);
    }
 
Example 16
Source File: ColorPickerPalette.java    From android-kernel-tweaker with GNU General Public License v3.0 5 votes vote down vote up
/**
 * Creates a color swatch.
 */
private ColorPickerSwatch createColorSwatch(int color, int selectedColor) {
    ColorPickerSwatch view = new ColorPickerSwatch(getContext(), color,
            color == selectedColor, mOnColorSelectedListener);
    TableRow.LayoutParams params = new TableRow.LayoutParams(mSwatchLength, mSwatchLength);
    params.setMargins(mMarginSize, mMarginSize, mMarginSize, mMarginSize);
    view.setLayoutParams(params);
    return view;
}
 
Example 17
Source File: TableLayout.java    From appinventor-extensions with Apache License 2.0 4 votes vote down vote up
private static TableRow.LayoutParams newCellLayoutParams() {
  return new TableRow.LayoutParams();
}
 
Example 18
Source File: CheckersLayout.java    From privacy-friendly-dame with GNU General Public License v3.0 4 votes vote down vote up
public CheckersLayout(CheckersGame game, GameActivity activity) {
    super(activity);
    myActivity = activity;

    DisplayMetrics displayMetrics = getContext().getResources().getDisplayMetrics();
    int dimension = displayMetrics.widthPixels;
    if (displayMetrics.heightPixels < dimension) {
        dimension = displayMetrics.heightPixels;
    }
    int cellDimension = dimension / 8 ;

    LayoutParams params;

    myGame = game;
    Board myBoard = myGame.getBoard();

    params = new LayoutParams(
            ViewGroup.LayoutParams.WRAP_CONTENT,
            ViewGroup.LayoutParams.WRAP_CONTENT);
    params.setMargins(4, 4, 4, 4);
    setLayoutParams(params);
    setBackgroundColor(getResources().getColor(R.color.cellBlack));

    // add table of image views
    cells = new CheckerImageView[8][8];
    for (int y = 0; y < 8; y++) {
        TableRow row = new TableRow(activity);
        TableLayout.LayoutParams tableParams = new TableLayout.LayoutParams(
                ViewGroup.LayoutParams.WRAP_CONTENT,
                ViewGroup.LayoutParams.WRAP_CONTENT);
        tableParams.setMargins(0, 0, 0, 0);
        row.setLayoutParams(tableParams);

        for (int x = 0; x < 8; x++) {
            CheckerImageView cell;
            cells[x][y] = cell = new CheckerImageView(activity);
            cell.x = x;
            cell.y = y;

            TableRow.LayoutParams rowParams = new TableRow.LayoutParams(
                    ViewGroup.LayoutParams.MATCH_PARENT,
                    ViewGroup.LayoutParams.MATCH_PARENT);
            rowParams.setMargins(0, 0, 0, 0);
            rowParams.width = cellDimension;
            rowParams.height = cellDimension;
            cell.setLayoutParams(rowParams);

            int bgColor;
            if (myBoard.isGameSquare(x,y)) {
                // add click handler
                cell.setOnClickListener(CellClick);
                bgColor = getResources().getColor(R.color.cellBlack);
            }
            else {
                bgColor = getResources().getColor(R.color.cellWhite);
            }

            cell.setBackgroundColor(bgColor);
            row.addView(cell);
        }
        addView(row);
    }
}
 
Example 19
Source File: IPSettingActivity.java    From faceswap with Apache License 2.0 4 votes vote down vote up
private void addPersonUIRow(final SharedPreferences mSharedPreferences, final int type,
                            final String name, String ip) {
    final TableLayout tb=tbs[type];

    //create a new table row
    final TableRow tr = new TableRow(this);
    TableRow.LayoutParams trTlp = new TableRow.LayoutParams(
            0,
            TableLayout.LayoutParams.WRAP_CONTENT
    );
    tr.setLayoutParams(trTlp);

    //create name view
    TextView nameView = new TextView(this);
    nameView.setText(name);
    nameView.setTextSize(20);
    TableRow.LayoutParams tlp1 = new TableRow.LayoutParams(
            TableLayout.LayoutParams.WRAP_CONTENT,
            TableLayout.LayoutParams.MATCH_PARENT
    );
    tlp1.column=0;
    nameView.setLayoutParams(tlp1);

    //create sub view
    TextView subView = new TextView(this);
    subView.setText(ip);
    subView.setTextSize(20);
    TableRow.LayoutParams tlp3 = new TableRow.LayoutParams(
            TableLayout.LayoutParams.WRAP_CONTENT,
            TableLayout.LayoutParams.MATCH_PARENT
    );
    tlp3.column=1;
    subView.setLayoutParams(tlp3);

    //create delete button
    ImageView deleteView = new ImageView(this);
    deleteView.setImageResource(R.drawable.ic_delete_black_24dp);
    TableRow.LayoutParams tlp4 = new TableRow.LayoutParams(
            TableLayout.LayoutParams.WRAP_CONTENT,
            TableLayout.LayoutParams.MATCH_PARENT
    );
    tlp4.column=2;
    deleteView.setLayoutParams(tlp4);
    deleteView.setOnClickListener(new ImageView.OnClickListener() {
        @Override
        public void onClick(View v) {
            //remove name from sharedPreferences
            String sharedPreferenceIpDictName=
                    getResources().getStringArray(R.array.shared_preference_ip_dict_names)[type];
            SharedPreferences.Editor editor = mSharedPreferences.edit();
            Set<String> existingNames =
                    new HashSet<String>(mSharedPreferences.getStringSet(sharedPreferenceIpDictName,
                            new HashSet<String>()));
            editor.remove(name);
            existingNames.remove(name);
            editor.putStringSet(sharedPreferenceIpDictName, existingNames);
            editor.commit();

            //remove current line from UI
            tb.removeView(tr);
        }
    });

    tr.addView(nameView);
    tr.addView(subView);
    tr.addView(deleteView);

    tb.addView(tr,
            new TableLayout.LayoutParams(TableLayout.LayoutParams.MATCH_PARENT,
                    TableLayout.LayoutParams.WRAP_CONTENT));
}
 
Example 20
Source File: TimetableView.java    From TimetableView with Apache License 2.0 4 votes vote down vote up
private TableRow.LayoutParams createTableRowParam(int w_px, int h_px) {
    return new TableRow.LayoutParams(w_px, h_px);
}