本文整理汇总了Java中android.widget.TableRow.setBackgroundColor方法的典型用法代码示例。如果您正苦于以下问题:Java TableRow.setBackgroundColor方法的具体用法?Java TableRow.setBackgroundColor怎么用?Java TableRow.setBackgroundColor使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类android.widget.TableRow
的用法示例。
在下文中一共展示了TableRow.setBackgroundColor方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: getTableRow
import android.widget.TableRow; //导入方法依赖的package包/类
public static TableRow getTableRow(Context context, View... views){
TableRow tableRow = new TableRow(context);
tableRow.setLayoutParams(new TableRow.LayoutParams(TableRow.LayoutParams.MATCH_PARENT,
TableRow.LayoutParams.WRAP_CONTENT));
tableRow.setBackgroundColor(Color.GRAY);
for (View item: views) {
tableRow.addView(item);
}
return tableRow;
}
示例2: showTable
import android.widget.TableRow; //导入方法依赖的package包/类
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);
}
}
示例3: showTable
import android.widget.TableRow; //导入方法依赖的package包/类
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);
}
}
示例4: inflateTable
import android.widget.TableRow; //导入方法依赖的package包/类
private static TableLayout inflateTable(Context context, String tableContent, String[] extras,
boolean isFirstView, boolean isLastView) {
TableLayout tableLayout = new TableLayout(context);
String[] rows = tableContent.split(Content.TABLE_ROW_DIVIDER);
int primaryColor = ContextCompat.getColor(context, R.color.colorPrimary);
int stripColor = Color.argb(35, Color.red(primaryColor), Color.green(primaryColor), Color.blue(primaryColor));
TableLayout.LayoutParams tableParams = new TableLayout.LayoutParams(LinearLayout.LayoutParams.MATCH_PARENT,
LinearLayout.LayoutParams.WRAP_CONTENT);
TableRow.LayoutParams rowParams = new TableRow.LayoutParams(LinearLayout.LayoutParams.MATCH_PARENT,
LinearLayout.LayoutParams.WRAP_CONTENT);
tableLayout.setLayoutParams(tableParams);
tableLayout.setStretchAllColumns(true);
for (int i = 0; i < rows.length; i++) {
TableRow tableRow = new TableRow(context);
tableRow.setLayoutParams(rowParams);
if (Arrays.asList(extras).contains(Content.EXTRA_HAS_STRIPES) && i % 2 != 0)
tableRow.setBackgroundColor(stripColor);
if (Arrays.asList(extras).contains(Content.EXTRA_HAS_HEADER) && i == 0)
tableRow.setBackgroundResource(R.drawable.bottom_tablerow_border);
String[] rowCells = rows[i].split(Content.TABLE_COLUMN_DIVIDER);
for (int j = 0; j < rowCells.length; j++) {
TextView tvCell = new TextView(context);
tvCell.setTextSize(TypedValue.COMPLEX_UNIT_SP, 16.0f);
tvCell.setText(rowCells[j]);
tvCell.setTextColor(ContextCompat.getColor(context, R.color.mainTextColor));
int padding = (int) TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_DIP, 8,
context.getResources().getDisplayMetrics());
tvCell.setPadding(padding, i == 0 ? 0 : padding, padding, padding);
if (Arrays.asList(extras).contains(Content.EXTRA_HAS_HEADER) && i == 0) {
tableRow.setBackgroundResource(R.drawable.bottom_tablerow_border);
tvCell.setTypeface(null, Typeface.BOLD);
}
if (j == rowCells.length - 1)
tvCell.setGravity(GravityCompat.END);
tableRow.addView(tvCell);
}
tableLayout.addView(tableRow);
}
if (isFirstView && isLastView)
setViewMargins(tableLayout, 0, defaultMargin, 0, 0);
else if (isFirstView)
setViewMargins(tableLayout, 0, defaultMargin, 0, halfMargin);
else if (isLastView)
setViewMargins(tableLayout, 0, halfMargin, 0, 0);
else
setViewMargins(tableLayout, 0, halfMargin, 0, halfMargin);
return tableLayout;
}
示例5: setProperties
import android.widget.TableRow; //导入方法依赖的package包/类
private void setProperties(ArrayList<FileMeta> properties) {
this.properties = properties;
if (properties == null) {
propertiesCard.setVisibility(View.GONE);
return;
}
if (propertiesCard.getVisibility() != View.VISIBLE) {
propertiesCard.setVisibility(View.VISIBLE);
}
Analytics.EventBuilder analytics = Analytics.newEvent("busybox properties");
for (FileMeta property : properties) {
analytics.put(property.label, property.value);
}
analytics.log();
TableLayout tableLayout = getViewById(R.id.table_properties);
if (tableLayout.getChildCount() > 0) {
tableLayout.removeAllViews();
}
int width = ResUtils.dpToPx(128);
int left = ResUtils.dpToPx(16);
int top = ResUtils.dpToPx(6);
int bottom = ResUtils.dpToPx(6);
int i = 0;
for (FileMeta meta : properties) {
TableRow tableRow = new TableRow(getActivity());
TextView nameText = new TextView(getActivity());
TextView valueText = new TextView(getActivity());
if (i % 2 == 0) {
tableRow.setBackgroundColor(0x0D000000);
} else {
tableRow.setBackgroundColor(Color.TRANSPARENT);
}
nameText.setLayoutParams(new TableRow.LayoutParams(width, ViewGroup.LayoutParams.WRAP_CONTENT));
nameText.setPadding(left, top, 0, bottom);
nameText.setAllCaps(true);
nameText.setTypeface(Typeface.DEFAULT_BOLD);
nameText.setText(meta.name);
valueText.setPadding(left, top, 0, bottom);
valueText.setText(meta.value);
tableRow.addView(nameText);
tableRow.addView(valueText);
tableLayout.addView(tableRow);
i++;
}
}