本文整理匯總了Java中android.widget.TableLayout.LayoutParams方法的典型用法代碼示例。如果您正苦於以下問題:Java TableLayout.LayoutParams方法的具體用法?Java TableLayout.LayoutParams怎麽用?Java TableLayout.LayoutParams使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類android.widget.TableLayout
的用法示例。
在下文中一共展示了TableLayout.LayoutParams方法的9個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: setViewMargin
import android.widget.TableLayout; //導入方法依賴的package包/類
/**
* 設置View的Margin
*
* @param view
* @param left
* @param top
* @param right
* @param bottom
* @param width
* @param height
*/
public void setViewMargin(View view, int left, int top, int right, int bottom, int width, int height) {
if (view == null) {
return;
}
ViewParent parent = view.getParent();
if (parent == null) {
return;
}
ViewGroup.MarginLayoutParams lp;
if (parent instanceof LinearLayout) {
lp = new LinearLayout.LayoutParams(width, height);
} else if (parent instanceof RelativeLayout) {
lp = new RelativeLayout.LayoutParams(width, height);
} else if (parent instanceof FrameLayout) {
lp = new FrameLayout.LayoutParams(width, height);
} else {
lp = new TableLayout.LayoutParams(width, height);
}
if (lp != null) {
lp.setMargins(left, top, right, bottom);
view.setLayoutParams(lp);
}
}
示例2: makeRemarkList
import android.widget.TableLayout; //導入方法依賴的package包/類
private void makeRemarkList(){
if(remarks.size() > 0){
tv_msg_remark.setVisibility(View.GONE);
}else{
tv_msg_remark.setVisibility(View.VISIBLE);
}
for(PatientRemark pr : remarks){
TableLayout.LayoutParams tlps=new TableLayout.LayoutParams(TableLayout.LayoutParams.WRAP_CONTENT,TableLayout.LayoutParams.WRAP_CONTENT);
TableRow.LayoutParams trps=new TableRow.LayoutParams(TableRow.LayoutParams.WRAP_CONTENT,TableRow.LayoutParams.WRAP_CONTENT);
TableRow tr = new TableRow(this);
tr.setLayoutParams(new TableRow.LayoutParams(TableRow.LayoutParams.MATCH_PARENT, TableRow.LayoutParams.WRAP_CONTENT));
TextView tv_title = new TextView(this);
tv_title.setText(pr.getDescription());
tv_title.setLayoutParams(trps);
tv_title.setTextColor(getColorId(R.color.dark_gray));
tv_title.setGravity(Gravity.CENTER);
tv_title.setTextSize(TypedValue.COMPLEX_UNIT_PX,
getResources().getDimension(R.dimen.default_font_small_size));
TextView tv_time = new TextView(this);
tv_time.setText(AdditionalFunc.getTimeString(pr.getRegisteredDate()));
tv_time.setLayoutParams(trps);
tv_time.setTextColor(getColorId(R.color.dark_gray));
tv_time.setGravity(Gravity.CENTER);
tv_time.setTextSize(TypedValue.COMPLEX_UNIT_PX,
getResources().getDimension(R.dimen.default_font_small_size));
tr.addView(tv_title);
tr.addView(tv_time);
tl_remark.addView(tr, tlps);
}
}
示例3: addButtonForNetwork
import android.widget.TableLayout; //導入方法依賴的package包/類
private void addButtonForNetwork(AccessPointInfo info) {
TableLayout s = (TableLayout) findViewById(R.id.table_networks);
TableLayout.LayoutParams tableParams = new TableLayout.LayoutParams(
LayoutParams.MATCH_PARENT, LayoutParams.WRAP_CONTENT);
TableRow row = new TableRow(this);
TableRow.LayoutParams rowParams = new TableRow.LayoutParams(LayoutParams.MATCH_PARENT,
LayoutParams.WRAP_CONTENT);
rowParams.gravity = Gravity.FILL_HORIZONTAL;
row.setPadding(10, 10, 10, 10);
row.setLayoutParams(rowParams);
row.setGravity(Gravity.FILL_HORIZONTAL);
row.setLayoutParams(rowParams);
NetworkButton button = new NetworkButton(this, info.getBssid());
TableRow.LayoutParams params = new TableRow.LayoutParams(LayoutParams.MATCH_PARENT,
LayoutParams.WRAP_CONTENT);
button.setLayoutParams(params);
button.setBackground(getResources().getDrawable(R.drawable.repwifi_button));
button.setTextColor(Commons.colorThemeLight);
button.setTextSize(20);
button.setPadding(25, 10, 25, 10);
button.setGravity(Gravity.CENTER_HORIZONTAL);
button.setText(info.getSsid(20));
button.setOnClickListener(this);
row.addView(button, params);
row.setGravity(Gravity.CENTER_HORIZONTAL);
s.addView(row, tableParams);
s.setGravity(Gravity.FILL_HORIZONTAL);
}
示例4: onBindViewHolder
import android.widget.TableLayout; //導入方法依賴的package包/類
@Override
public void onBindViewHolder(final ViewHolder holder, int position) {
final MainRecord mr = list.get(position);
final int pos = position;
holder.tv_dateTitle.setText(mr.getDate());
ArrayList<MainRecord> groupList = mr.getGroupList();
for(int i=0; i<groupList.size(); i++){
MainRecord mr2 = groupList.get(i);
VitalSign vs = (VitalSign)mr2;
TableLayout.LayoutParams tlps=new TableLayout.LayoutParams(TableLayout.LayoutParams.WRAP_CONTENT,TableLayout.LayoutParams.WRAP_CONTENT);
TableRow.LayoutParams trps=new TableRow.LayoutParams(TableRow.LayoutParams.WRAP_CONTENT,TableRow.LayoutParams.WRAP_CONTENT);
TableRow tr = new TableRow(context);
tr.setLayoutParams(new TableRow.LayoutParams(TableRow.LayoutParams.MATCH_PARENT, TableRow.LayoutParams.WRAP_CONTENT));
TextView tv_title = new TextView(context);
switch (type){
case InquiryVitalSignFragment.TYPE_PULSE: {
tv_title.setText(vs.getPulse() + "");
break;
}
case InquiryVitalSignFragment.TYPE_TEMPERATURE:{
tv_title.setText(vs.getTemperature() + "");
break;
}
case InquiryVitalSignFragment.TYPE_BP:{
tv_title.setText(vs.getBpMin() + " / " + vs.getBpMax());
break;
}
}
tv_title.setLayoutParams(trps);
tv_title.setTextColor(recordSupporter.getColorId(R.color.dark_gray));
tv_title.setGravity(Gravity.CENTER);
tv_title.setTextSize(TypedValue.COMPLEX_UNIT_PX,
context.getResources().getDimension(R.dimen.default_font_small_size));
tr.addView(tv_title);
TextView tv_time = new TextView(context);
tv_time.setText(AdditionalFunc.getTimeString(vs.getRegisteredDate()));
tv_time.setLayoutParams(trps);
tv_time.setTextColor(recordSupporter.getColorId(R.color.dark_gray));
tv_time.setGravity(Gravity.CENTER);
tv_time.setTextSize(TypedValue.COMPLEX_UNIT_PX,
context.getResources().getDimension(R.dimen.default_font_small_size));
tr.addView(tv_time);
holder.tl.addView(tr, tlps);
}
}
示例5: makeMealList
import android.widget.TableLayout; //導入方法依賴的package包/類
private void makeMealList(){
if(haveMeals.size() > 0){
tv_msg_meal.setVisibility(View.GONE);
}else{
tv_msg_meal.setVisibility(View.VISIBLE);
}
for(HaveMeal hm : haveMeals){
TableLayout.LayoutParams tlps=new TableLayout.LayoutParams(TableLayout.LayoutParams.WRAP_CONTENT,TableLayout.LayoutParams.WRAP_CONTENT);
TableRow.LayoutParams trps=new TableRow.LayoutParams(TableRow.LayoutParams.WRAP_CONTENT,TableRow.LayoutParams.WRAP_CONTENT);
TableRow tr = new TableRow(this);
tr.setLayoutParams(new TableRow.LayoutParams(TableRow.LayoutParams.MATCH_PARENT, TableRow.LayoutParams.WRAP_CONTENT));
TextView tv_title = new TextView(this);
if("nursing_home".equals(hm.getType())){
tv_title.setText(getString(R.string.nursing_home_meal_srt));
}else if("water_gruel".equals(hm.getType())){
tv_title.setText(getString(R.string.water_gruel));
}else{
tv_title.setText(hm.getType());
}
tv_title.setLayoutParams(trps);
tv_title.setTextColor(getColorId(R.color.dark_gray));
tv_title.setGravity(Gravity.CENTER);
tv_title.setTextSize(TypedValue.COMPLEX_UNIT_PX,
getResources().getDimension(R.dimen.default_font_small_size));
TextView tv_time = new TextView(this);
tv_time.setText(AdditionalFunc.getTimeString(hm.getRegisteredDate()));
tv_time.setLayoutParams(trps);
tv_time.setTextColor(getColorId(R.color.dark_gray));
tv_time.setGravity(Gravity.CENTER);
tv_time.setTextSize(TypedValue.COMPLEX_UNIT_PX,
getResources().getDimension(R.dimen.default_font_small_size));
tr.addView(tv_title);
tr.addView(tv_time);
tl_meal.addView(tr, tlps);
}
}
示例6: makeList
import android.widget.TableLayout; //導入方法依賴的package包/類
private void makeList(String type){
ArrayList<NearbyLog> list = new ArrayList<>();
TableLayout tl = null;
switch (type){
case "symptom": {
list = symptomList;
tl = tl_symptom;
break;
}
case "medicine": {
list = medicineList;
tl = tl_medicine;
break;
}
case "record": {
list = recordList;
tl = tl_record;
break;
}
case "weight": {
list = weightList;
tl = tl_weight;
break;
}
case "edit_patient": {
list = editPatientList;
tl = tl_edit_patient;
break;
}
case "supporter": {
list = supporterList;
tl = tl_supporter;
break;
}
}
if(tl != null){
for(int i= Math.max(0, list.size()-5); i<list.size(); i++){
NearbyLog log = list.get(i);
TableLayout.LayoutParams tlps=new TableLayout.LayoutParams(TableLayout.LayoutParams.WRAP_CONTENT,TableLayout.LayoutParams.WRAP_CONTENT);
TableRow.LayoutParams trps=new TableRow.LayoutParams(TableRow.LayoutParams.WRAP_CONTENT,TableRow.LayoutParams.WRAP_CONTENT);
TableRow tr = new TableRow(this);
tr.setLayoutParams(new TableRow.LayoutParams(TableRow.LayoutParams.MATCH_PARENT, TableRow.LayoutParams.WRAP_CONTENT));
TextView tv_log_msg = new TextView(this);
tv_log_msg.setText(log.getMsg());
tv_log_msg.setLayoutParams(trps);
tv_log_msg.setTextColor(getColorId(R.color.dark_gray));
tv_log_msg.setGravity(Gravity.CENTER);
tv_log_msg.setTextSize(TypedValue.COMPLEX_UNIT_PX,
getResources().getDimension(R.dimen.default_font_small_size));
TextView tv_time = new TextView(this);
tv_time.setText(AdditionalFunc.getDateTimeSrtString(log.getRegisteredDate()));
tv_time.setLayoutParams(trps);
tv_time.setTextColor(getColorId(R.color.dark_gray));
tv_time.setGravity(Gravity.CENTER);
tv_time.setTextSize(TypedValue.COMPLEX_UNIT_PX,
getResources().getDimension(R.dimen.default_font_small_size));
tr.addView(tv_log_msg);
tr.addView(tv_time);
tl.addView(tr, tlps);
}
}
}
示例7: resize
import android.widget.TableLayout; //導入方法依賴的package包/類
public void resize(int rows, int cols, int cellLayoutId)
{
if (rowsNumber == rows && colsNumber == cols)
{
return;
}
rowsNumber = rows;
colsNumber = cols;
removeAllViews();
fields.clear();
final TableLayout.LayoutParams tableParams = new TableLayout.LayoutParams(
TableLayout.LayoutParams.WRAP_CONTENT, TableLayout.LayoutParams.WRAP_CONTENT);
final LayoutInflater inflater = (LayoutInflater) getContext().getSystemService(
Context.LAYOUT_INFLATER_SERVICE);
for (int row = 0; row < rowsNumber; row++)
{
final TableRow tableRow = new TableRow(getContext());
tableRow.setLayoutParams(tableParams); // TableLayout is the parent view
addView(tableRow);
for (int col = 0; col < colsNumber; col++)
{
inflater.inflate(cellLayoutId, tableRow);
}
if (tableRow.getChildCount() > 0)
{
tableRow.setBaselineAligned(true);
tableRow.setBaselineAlignedChildIndex(0);
}
for (int col = 0; col < tableRow.getChildCount(); col++)
{
final CustomEditText c = (CustomEditText) tableRow.getChildAt(col);
if (c != null)
{
c.setId(IdGenerator.generateId());
c.setTag(new ElementTag(row, col, fields.size()));
fields.add(c);
}
}
}
setPadding(0, 0, 0, 0);
setBaselineAligned(true);
setBaselineAlignedChildIndex(rowsNumber > 1 ? rowsNumber / 2 : 0);
}
示例8: inflateTable
import android.widget.TableLayout; //導入方法依賴的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;
}
示例9: updateHorizontalSeparator
import android.widget.TableLayout; //導入方法依賴的package包/類
private void updateHorizontalSeparator(TableRow tableRow) {
TableLayout.LayoutParams tableRowParams = (TableLayout.LayoutParams) tableRow.getLayoutParams();
tableRowParams.setMargins(0, 0, 0, mHorizontalSeparatorMargin);
tableRow.setLayoutParams(tableRowParams);
}