Adding View to TableLayout Takes Up Whole Screen - android

I am simply trying to add a separator line under my header row in a table layout, but no matter what i set the width/height to in layoutparams, the view takes up the whole page.
TableLayout tl = (TableLayout)FindViewById(Resource.Id.counted);
TableRow row = new TableRow(this);
TextView itemNumber = new TextView(this);
TextView itemDesc = new TextView(this);
TextView quantity = new TextView(this);
itemNumber.Text = "Item Number";
var inlo = new TableRow.LayoutParams(1);
inlo.SetMargins(10, 10, 30, 10);
itemNumber.LayoutParameters = inlo;
itemDesc.Text = "Item Description";
var idlo = new TableRow.LayoutParams(2);
idlo.SetMargins(10, 10, 30, 10);
itemDesc.LayoutParameters = inlo;
quantity.Text = "Quantity";
var qlo = new TableRow.LayoutParams(3);
qlo.SetMargins(10, 10, 30, 10);
quantity.LayoutParameters = qlo;
View v = new View(this);
v.LayoutParameters = new TableRow.LayoutParams(ViewGroup.LayoutParams.FillParent | 0);
v.SetBackgroundColor(Android.Graphics.Color.White);
row.AddView(itemNumber);
row.AddView(itemDesc);
row.AddView(quantity);
tl.AddView(row);
tl.AddView(v);
v and its white background takes up the whole screen below row. ????

Just decided to use Strings to underline my column headers rather than trying to put a line under the first row.

Related

Dynamic Content with wrap text not working

I want to build a dynamic table which will have TextView with some content. It could happen that the text is long, in that case, I want my text to be wrapped. But in the code given below it does not work. I tried adding layout parameters to my TextView with weight=1 does not work.
Here is my code:
table = FindViewById<TableLayout>(Resource.Id.main_table);
TableRow tr_head = new TableRow(this);
tr_head.Id = 10;
tr_head.SetBackgroundColor(Color.Gray);
TableRow.LayoutParams paramTableRow = new TableRow.LayoutParams(LayoutParams.MatchParent,
LayoutParams.WrapContent);
tr_head.LayoutParameters = paramTableRow;
LinearLayout.LayoutParams paramcell = new LinearLayout.LayoutParams(LayoutParams.WrapContent,LayoutParams.WrapContent,1.0f);
TextView label_Buyway = new TextView(this);
label_Buyway.Id=20;
label_Buyway.Text ="Buyway";
label_Buyway.SetTextColor(Color.Black);
label_Buyway.SetPadding(5, 5, 5, 5);
tr_head.AddView(label_Buyway);
TextView label_qty = new TextView(this);
label_qty.Id=21;
label_qty.Text="Qty";
label_qty.SetTextColor(Color.Black);
label_qty.SetPadding(5, 5, 5, 5);
tr_head.AddView(label_qty);
TextView label_price = new TextView(this);
label_price.Id = 22;
label_price.Text = "Price";
label_price.SetTextColor(Color.Black);
label_price.SetPadding(5, 5, 5, 5);
tr_head.AddView(label_price);
TextView label_total = new TextView(this);
label_total.Id = 23;
label_total.Text = "Total";
label_total.SetTextColor(Color.Black);
label_total.SetPadding(5, 5, 5, 5);
tr_head.AddView(label_total);
table.AddView(tr_head, new TableLayout.LayoutParams(
LayoutParams.MatchParent,
LayoutParams.WrapContent));
for (int i = 0; i < 10; i++)
{
string date = DateTime.Now.ToString();
Double weight_kg = 1.1;
TableRow tr = new TableRow(this);
tr.Id=(100 + i);
tr.LayoutParameters = paramTableRow;
TextView labelBuyway = new TextView(this);
labelBuyway.Id=(200 + i);
labelBuyway.Text =date;
labelBuyway.SetTextColor(Color.Black);
labelBuyway.SetBackgroundResource(Resource.Drawable.table_row);
labelBuyway.LayoutParameters = paramcell;
tr.AddView(labelBuyway);
TextView labelqty = new TextView(this);
labelqty.Id=(200 + i);
labelqty.Text=(weight_kg.ToString());
labelqty.SetTextColor(Color.Black);
labelqty.SetBackgroundResource(Resource.Drawable.table_row);
tr.AddView(labelqty);
TextView labelPrice = new TextView(this);
labelPrice.Id = (200 + i);
labelPrice.Text = (weight_kg.ToString());
labelPrice.SetTextColor(Color.Black);
labelPrice.SetBackgroundResource(Resource.Drawable.table_row);
tr.AddView(labelPrice);
TextView labelTotal = new TextView(this);
labelTotal.Id = (200 + i);
labelTotal.Text = (weight_kg.ToString());
labelTotal.SetTextColor(Color.Black);
labelTotal.SetBackgroundResource(Resource.Drawable.table_row);
tr.AddView(labelTotal);
table.AddView(tr, new TableLayout.LayoutParams(
LayoutParams.MatchParent,
LayoutParams.WrapContent));
i++;
}
Right now the text gets cut and does not wrap. Any help would be appreciated.
What I guess is these three lines would do the trick :
textViewName.HorizontalScrollBarEnabled = false;
textViewName.SetMinLines(2);
textViewName.InputType = Android.Text.InputTypes.TextFlagMultiLine;
with the weight property set to 1 and these three properties, it should work.
Please revert whether it works.
give your textviews with weight=1 and Wrap content. SO it will expand according to the text size.

How to show textview left alignment in android

In my application i want to show VIEW ALL to left align like below image:-
But I found this type of layout and more thing i also do all these layout programmatically.
My SourceCode:-
private void printFrontCategory(){
for(int i=0;i<main.size();i++) {
View v = new View(MainActivity.this);
v.setLayoutParams(new RadioGroup.LayoutParams(RadioGroup.LayoutParams.FILL_PARENT, 5));
v.setBackgroundColor(Color.rgb(51, 51, 51));
/* View v1 = new View(MainActivity.this);
v1.setLayoutParams(new RadioGroup.LayoutParams(RadioGroup.LayoutParams.FILL_PARENT,5));
v1.setBackgroundColor(Color.rgb(255, 255, 255));*/
HorizontalScrollView horizontalScrollView = new HorizontalScrollView(MainActivity.this);
horizontalScrollView.setHorizontalScrollBarEnabled(false);
TextView textView = new TextView(MainActivity.this);
String content = front_category_catetory_name.get(i);
content = content.replace("'", "");
content = content.replace("&","");
textView.setText(content);
textView.setGravity(Gravity.RIGHT);
// textView.setGravity(Gravity.CENTER);
textView.setTextSize(20);
TextView textView2 = new TextView(MainActivity.this);
textView2.setText("VIEW ALL");
textView2.setTextColor(Color.BLUE);
textView2.setGravity(Gravity.LEFT);
LinearLayout linearLayout2 = new LinearLayout(MainActivity.this);
linearLayout2.setOrientation(LinearLayout.HORIZONTAL);
linearLayout2.addView(textView,0);
linearLayout2.addView(textView2,1);
LinearLayout linearLayout = new LinearLayout(MainActivity.this);
linearLayout.setOrientation(LinearLayout.HORIZONTAL);
for (int j = 0; j < main.get(i).size(); j++) {
LinearLayout linearLayout1 = new LinearLayout(MainActivity.this);
linearLayout1.setOrientation(LinearLayout.VERTICAL);
ImageView image = new ImageView(MainActivity.this);
TextView nameProduct = new TextView(MainActivity.this);
TextView priceProduct = new TextView(MainActivity.this);
TextView special_discount = new TextView(MainActivity.this);
/* Log.d("counter val",cnt+"");
Log.d("thumb ",front_category_thumb.size()+"");
Log.d("image", front_category_thumb.get(52));*/
new SetImageView(image).execute(main.get(i).get(j).get(1));
nameProduct.setText(main.get(i).get(j).get(2));
if (!String.valueOf(main.get(i).get(j).get(5)).equals(null)) {
priceProduct.setText(main.get(i).get(j).get(3));
special_discount.setText(main.get(i).get(j).get(5));
priceProduct.setPaintFlags(nameProduct.getPaintFlags() | Paint.STRIKE_THRU_TEXT_FLAG);
priceProduct.setGravity(Gravity.CENTER);
special_discount.setGravity(Gravity.CENTER);
nameProduct.setGravity(Gravity.CENTER);
linearLayout1.addView(image);
linearLayout1.addView(nameProduct);
linearLayout1.addView(priceProduct);
linearLayout1.addView(special_discount);
} else if (!String.valueOf(main.get(i).get(j).get(4)).equals(null)) {
priceProduct.setText(main.get(i).get(j).get(3));
special_discount.setText(main.get(i).get(j).get(4));
priceProduct.setPaintFlags(nameProduct.getPaintFlags() | Paint.STRIKE_THRU_TEXT_FLAG);
priceProduct.setGravity(Gravity.CENTER);
special_discount.setGravity(Gravity.CENTER);
nameProduct.setGravity(Gravity.CENTER);
linearLayout1.addView(image);
linearLayout1.addView(nameProduct);
linearLayout1.addView(priceProduct);
linearLayout1.addView(special_discount);
} else {
priceProduct.setText(main.get(i).get(j).get(3));
priceProduct.setGravity(Gravity.CENTER);
nameProduct.setGravity(Gravity.CENTER);
linearLayout1.addView(image);
linearLayout1.addView(nameProduct);
linearLayout1.addView(priceProduct);
}
linearLayout.addView(linearLayout1, j);
}
horizontalScrollView.addView(linearLayout);
// linearLayoutmens.addView(textView);
// linearLayoutmens.addView(v1);
linearLayoutmens.addView(linearLayout2);
linearLayoutmens.addView(horizontalScrollView);
linearLayoutmens.addView(v);
}
}
I am new in android programming. Please help me!
If you haven't found solution yet, then you can try the following
textView.setGravity(Gravity.RIGHT); This basically act as Gravity for text within TextView for more info refer So basically it is counter part of android:Gravity. Hence we need LayoutParam
Your problem it can be solved in two ways using LinearLayout and RelativeLayout change the below code from
TextView textView = new TextView(MainActivity.this);
String content = front_category_catetory_name.get(i);
content = content.replace("'", "");
content = content.replace("&","");
textView.setText(content);
textView.setGravity(Gravity.RIGHT);
// textView.setGravity(Gravity.CENTER);
textView.setTextSize(20);
TextView textView2 = new TextView(MainActivity.this);
textView2.setText("VIEW ALL");
textView2.setTextColor(Color.BLUE);
textView2.setGravity(Gravity.LEFT);
LinearLayout linearLayout2 = new LinearLayout(MainActivity.this);
linearLayout2.setOrientation(LinearLayout.HORIZONTAL);
linearLayout2.addView(textView,0);
linearLayout2.addView(textView2,1);
Solution1 Using LinearLayout
TextView textView = new TextView(MainActivity.this);
String content = front_category_catetory_name.get(i);
content = content.replace("'", "");
content = content.replace("&","");
textView.setText(content);
textView.setGravity(Gravity.START); //Gravity.Left also works
textView.setTextSize(20);
TextView textView2 = new TextView(MainActivity.this);
textView2.setText("VIEW ALL");
textView2.setTextColor(Color.BLUE);
textView2.setGravity(Gravity.END); //Gravity.Right also works
LinearLayout linearLayout2 = new LinearLayout(MainActivity.this);
linearLayout2.setOrientation(LinearLayout.HORIZONTAL);
LinearLayout.LayoutParams linearLayoutParam = new LinearLayout.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT,
ViewGroup.LayoutParams.WRAP_CONTENT,2);
linearLayout2.setLayoutParams(linearLayoutParam);
LinearLayout.LayoutParams viewParam = new LinearLayout.LayoutParams(ViewGroup.LayoutParams.WRAP_CONTENT,
ViewGroup.LayoutParams.WRAP_CONTENT,1);
linearLayout2.addView(textView, 0, viewParam);
linearLayout2.addView(textView2, 1, viewParam);
In above solution I have assigned weightSum = 2 to LinearLayout and weight=1 to each TextView.
Solution2 Using RelativeLayout
TextView textView = new TextView(MainActivity.this);
String content = front_category_catetory_name.get(i);
content = content.replace("'", "");
content = content.replace("&","");
textView.setText(content);
//textView.setGravity(Gravity.START); //Gravity.Left also works
textView.setTextSize(20);
TextView textView2 = new TextView(MainActivity.this);
textView2.setText("VIEW ALL");
textView2.setTextColor(Color.BLUE);
//textView2.setGravity(Gravity.END); //Gravity.Right also works
RelativeLayout relativeLayout2 = new RelativeLayout(MainActivity.this);
RelativeLayout.LayoutParams relativeLayoutParam1 = new RelativeLayout.LayoutParams(ViewGroup.LayoutParams.WRAP_CONTENT, ViewGroup.LayoutParams.WRAP_CONTENT);
relativeLayoutParam1.addRule(RelativeLayout.ALIGN_PARENT_LEFT);
relativeLayout2.addView(textView, 0, relativeLayoutParam1);
RelativeLayout.LayoutParams relativeLayoutParam2 = new RelativeLayout.LayoutParams(ViewGroup.LayoutParams.WRAP_CONTENT, ViewGroup.LayoutParams.WRAP_CONTENT);
relativeLayoutParam2.addRule(RelativeLayout.ALIGN_PARENT_RIGHT);
relativeLayout2.addView(textView2, 1, relativeLayoutParam2);
In this case textView.setGravity(Gravity.RIGHT); is optional.
Update Based on comment
If you want underlined text as in SAMPLE below then check one of the answer here
<u>Sample</u>
But if you want a black line then it is view and you need to add it after adding linearlayout2 or relativelayout2 depending upon the solution in the main view.

TableLayout gets empty after phone position is changed

I got problem with my TableLayout using code - adding rows dynamically.
Whenever I change position of my phone from horizontal to vertical or vertical to horizontal all the data that was inputted to my table is getting removed and table is empty. The only things that are left are column headers (TextViews) with names coded in my program.
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
final TableLayout tableOne = (TableLayout) findViewById(R.id.dataTable1);
tableOne.setId(110);
tableOne.setBackgroundColor(Color.WHITE);
TableRow namesRow = new TableRow(MainActivity.this);
namesRow.setId(111);
namesRow.setBackgroundColor(Color.GRAY);
namesRow.setLayoutParams(new LayoutParams(LayoutParams.MATCH_PARENT, LayoutParams.WRAP_CONTENT));
TextView productName = new TextView(MainActivity.this);
productName.setId(120);
productName.setPadding(2, 0, 40, 5);
productName.setTextSize(14);
productName.setTextColor(Color.BLACK);
productName.setText("Product Name");
namesRow.addView(productName);
TextView concentration = new TextView(MainActivity.this);
concentration.setId(130);
concentration.setPadding(0, 0, 40, 5);
concentration.setTextColor(Color.BLACK);
concentration.setTextSize(14);
concentration.setText("Concentration");
namesRow.addView(concentration);
TextView packages = new TextView(MainActivity.this);
packages.setId(140);
packages.setPadding(0, 0, 40, 5);
packages.setTextSize(14);
packages.setTextColor(Color.BLACK);
packages.setText("Packages");
namesRow.addView(packages);
TextView volume = new TextView(MainActivity.this);
volume.setId(150);
volume.setPadding(0, 0, 40, 5);
volume.setTextSize(14);
volume.setTextColor(Color.BLACK);
volume.setText("Volume");
namesRow.addView(volume);
TextView totalamount = new TextView(MainActivity.this);
totalamount.setId(160);
totalamount.setPadding(0, 0, 40, 5);
totalamount.setTextSize(14);
totalamount.setTextColor(Color.BLACK);
totalamount.setText("Total Mass");
namesRow.addView(totalamount);
TextView sacksnumber = new TextView(MainActivity.this);
sacksnumber.setId(170);
sacksnumber.setPadding(0, 0, 40, 5);
sacksnumber.setText("Number of Sacks");
sacksnumber.setTextColor(Color.BLACK);
sacksnumber.setTextSize(14);
namesRow.addView(sacksnumber);
tableOne.addView(namesRow, new LayoutParams(LayoutParams.MATCH_PARENT, LayoutParams.WRAP_CONTENT));
The above code is fine and never disappears but below code when I create each row from data from EditText is disappearing once I change position of the code. Kind of like it resets...
Button sncbtn1 = (Button) findViewById(R.id.sncbtn);
sncbtn1.setOnClickListener(new OnClickListener() {
#Override
public void onClick(View v) {
EditText dataName = (EditText) findViewById(R.id.productField);
EditText dataConc = (EditText) findViewById(R.id.concField);
EditText dataPack = (EditText) findViewById(R.id.packageField);
EditText dataVol = (EditText) findViewById(R.id.volField);
String prodName = dataName.getText().toString();
String concValue = dataConc.getText().toString();
String packValue = dataPack.getText().toString();
String volValue = dataVol.getText().toString();
double concDoub = Double.parseDouble(concValue);
double packDoub = Double.parseDouble(packValue);
double volDoub = Double.parseDouble(volValue);
double massResult = volDoub * concDoub;
double sacksResult = massResult / packDoub;
System.out.println(prodName + " | " + concValue + " | " + packValue + " | " + volValue);
TableRow dataRow = new TableRow(MainActivity.this);
dataRow.setLayoutParams(new LayoutParams(LayoutParams.MATCH_PARENT, LayoutParams.WRAP_CONTENT));
if(tableOne.getChildCount() % 2 == 0) dataRow.setBackgroundColor(Color.LTGRAY);
TextView prodTable = new TextView(MainActivity.this);
prodTable.setText(prodName);
prodTable.setTextSize(14);
prodTable.setTextColor(Color.BLACK);
prodTable.setGravity(Gravity.CENTER);
dataRow.addView(prodTable);
TextView concTable = new TextView(MainActivity.this);
concTable.setText(concValue);
concTable.setTextColor(Color.BLACK);
concTable.setTextSize(14);
concTable.setGravity(Gravity.CENTER);
dataRow.addView(concTable);
TextView packTable = new TextView(MainActivity.this);
packTable.setText(packValue);
packTable.setTextSize(14);
packTable.setTextColor(Color.BLACK);
packTable.setGravity(Gravity.CENTER);
dataRow.addView(packTable);
TextView volTable = new TextView(MainActivity.this);
volTable.setText(volValue);
volTable.setTextSize(14);
volTable.setTextColor(Color.BLACK);
volTable.setGravity(Gravity.CENTER);
dataRow.addView(volTable);
TextView massTable = new TextView(MainActivity.this);
massTable.setText(new DecimalFormat("0.00").format(massResult));
massTable.setTextSize(14);
massTable.setTextColor(Color.BLACK);
massTable.setGravity(Gravity.CENTER);
dataRow.addView(massTable);
TextView sacksTable = new TextView(MainActivity.this);
sacksTable.setText(new DecimalFormat("0.00").format(sacksResult));
sacksTable.setTextColor(Color.BLACK);
sacksTable.setGravity(Gravity.CENTER);
sacksTable.setTextSize(14);
dataRow.addView(sacksTable);
tableOne.addView(dataRow, new LayoutParams(LayoutParams.MATCH_PARENT, LayoutParams.WRAP_CONTENT));
}
});
Also on my LogCat I'm getting error: getExtractedText on inactive InputConnection
I have tried to rewrite app with some tutorials/research etc thinking that I might find whats wrong but after 2 days I'm done and hopefully someone can help me.
Your onCreate gets called whenever your screen orientation is changed, one way to stop that is to add this line under your relevant activity tag in your manifest file:
android:configChanges="orientation|screenSize"
This way Android OS won't recreate the UI whenever the screen is rotated and leave it up to you.

Make TableLayout columns to fit perfectly the size of its contents programmatically

I'm trying to make a table in Android (API Level 10 minimum) where some of the columns have to stretch as more as possible whereas some need to shrink to fit its contents' size.
This is what I have:
(the colors are just to see the cells' width and height)
the 'at' column is what I am talking about. I need it to look like this one:
http://img268.imageshack.us/img268/1572/77141b8b8eb443d783cede5.png
Here is the code I am using for now:
ScrollView sv = new ScrollView(this);
TableLayout table = new TableLayout(this);
table.setShrinkAllColumns(true);
table.setStretchAllColumns(true);
table.setPadding(10, 10, 10, 10);
//title row
TableRow rowTitle = new TableRow(this);
rowTitle.setGravity(Gravity.CENTER_HORIZONTAL);
TextView title = new TextView(this);
title.setText("Majors - Season 10");
title.setTextSize(TypedValue.COMPLEX_UNIT_DIP, 18);
title.setGravity(Gravity.CENTER);
title.setTypeface(Typeface.SERIF, Typeface.BOLD);
TableRow.LayoutParams params = new TableRow.LayoutParams();
params.span = 4;
rowTitle.addView(title, params);
//header row
TableRow rowHeaders = new TableRow(this);
TextView away = new TextView(this);
away.setText("Away");
away.setTypeface(Typeface.DEFAULT_BOLD);
away.setGravity(Gravity.CENTER_HORIZONTAL);
rowHeaders.addView(away);
TextView empty = new TextView(this);
empty.setText(" ");
// empty.setGravity(Gravity.CENTER_HORIZONTAL);
empty.setBackgroundColor(Color.GREEN);
rowHeaders.addView(empty);
TextView home = new TextView(this);
home.setText("Home");
home.setTypeface(Typeface.DEFAULT_BOLD);
home.setGravity(Gravity.CENTER_HORIZONTAL);
rowHeaders.addView(home);
TextView score = new TextView(this);
score.setText("Score");
score.setTypeface(Typeface.DEFAULT_BOLD);
score.setGravity(Gravity.RIGHT);
rowHeaders.addView(score);
TableRow rowMatch = createMatchRow();
TableRow rowMatch2 = createMatchRow();
table.addView(rowTitle);
table.addView(rowHeaders);
table.addView(rowMatch);
table.addView(rowMatch2);
sv.addView(table);
return sv;
createMatchRow() is just a method that returns a TableRow for each of the matches. (Rows 2-)
Eh, fixed it by removing the
table.setShrinkAllColumns(true);
table.setStretchAllColumns(true);
and adding:
table.setColumnStretchable(0, true);
table.setColumnStretchable(2, true);

How does addView() of TableRow work?

I tried
private void addSnapPictureRow(TableLayout table, Bitmap bitmap) {
/*
* 1st row = TextView (Check In)
*/
TableRow row = new TableRow(this);
row.setGravity(Gravity.CENTER_HORIZONTAL);
// add text
TextView text = new TextView(this);
text.setText("Snap Picture");
TableRow.LayoutParams textLayoutParams = new TableRow.LayoutParams(TableRow.LayoutParams.MATCH_PARENT, TableRow.LayoutParams.WRAP_CONTENT);
textLayoutParams.setMargins(100, 0, 0, 0);
row.addView(text, textLayoutParams);
// add picture
ImageView picture = new ImageView(this);
picture.setImageResource(R.drawable.adium);
row.addView(picture);
/*
* 2nd row = View (separator)
*/
TableRow separator = new TableRow(this);
View line = new View(this);
TableRow.LayoutParams separatorLayoutParams = new TableRow.LayoutParams(TableRow.LayoutParams.MATCH_PARENT, 1);
separatorLayoutParams.setMargins(100, 0, 0, 0);
line.setBackgroundColor(Color.BLUE);
separator.addView(line, separatorLayoutParams);
// add row to table
table.addView(row);
// add a separator
table.addView(separator);
}
But the picture never showed. If I change the gravity to CENTER_HORIZONTAL, then it shows only a small part of the picture.
When create table with xml, I thought it automatically aligned horizontally. I can't understand how TableRow layout works. Could anyone shed me some lights on this?
Adding an extra LinearLayout for each row solved my problem ;). The algignment of the previous row cause the picture go out of screen.
private void addSnapPictureRow(TableLayout table, Bitmap bitmap) {
/*
* 1st row = TextView (Check In)
*/
TableRow row = new TableRow(this);
LinearLayout outerLayout = new LinearLayout(this);
// add text
TextView text = new TextView(this);
text.setText("Snap Picture");
LinearLayout.LayoutParams textLayoutParams = new LinearLayout.LayoutParams(LinearLayout.LayoutParams.WRAP_CONTENT, LinearLayout.LayoutParams.WRAP_CONTENT);
textLayoutParams.setMargins(100, 0, 0, 0);
// add picture
ImageView picture = new ImageView(this);
LinearLayout.LayoutParams pictureLayoutParams = new LinearLayout.LayoutParams(LinearLayout.LayoutParams.WRAP_CONTENT, LinearLayout.LayoutParams.WRAP_CONTENT);
picture.setImageResource(R.drawable.adium);
pictureLayoutParams.setMargins(20, 0, 0, 0);
outerLayout.addView(text, textLayoutParams);
outerLayout.addView(picture, pictureLayoutParams);
row.addView(outerLayout);
/*
* 2nd row = View (separator)
*/
TableRow separator = new TableRow(this);
View line = new View(this);
TableRow.LayoutParams separatorLayoutParams = new TableRow.LayoutParams(400, 1);
separatorLayoutParams.setMargins(100, 0, 0, 0);
line.setBackgroundColor(Color.BLUE);
separator.addView(line, separatorLayoutParams);
// add row to table
table.addView(row);
// add a separator
table.addView(separator);
}

Categories

Resources