本文整理了Java中android.widget.TextView.setWidth()
方法的一些代码示例,展示了TextView.setWidth()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。TextView.setWidth()
方法的具体详情如下:
包路径:android.widget.TextView
类名称:TextView
方法名:setWidth
暂无
代码示例来源:origin: stackoverflow.com
tv.setWidth(240);
tv.setPadding(4, 0, 4, 10);
ll.addView(tv);
代码示例来源:origin: stackoverflow.com
tv.setWidth(240);
tv.setPadding(4, 0, 4, 10);
ll.addView(tv);
代码示例来源:origin: TommyLemon/APIJSON
tvTabs[i].setWidth(maxWidth);
代码示例来源:origin: TommyLemon/Android-ZBLibrary
tvTabs[i].setWidth(maxWidth);
代码示例来源:origin: rey5137/material
v.setWidth(a.getDimensionPixelSize(attr, -1));
代码示例来源:origin: limxing/LFRecyclerView-Android
public MasonryView(View itemView) {
super(itemView);
textView = (TextView) itemView.findViewById(R.id.text);
textView.setWidth(500);
}
代码示例来源:origin: stackoverflow.com
View tabView = null;
if (mTabViewLayoutId != 0) {
tabView = LayoutInflater.from(getContext()).inflate(
mTabViewLayoutId, mTabStrip, false);
TextView tabTitleView = (TextView) tabView
.findViewById(mTabViewTextViewId);
tabTitleView.setWidth(getResources().getDisplayMetrics().widthPixels
/ mNumberOfTabs);
}
代码示例来源:origin: stackoverflow.com
int titleId = getResources().getIdentifier("action_bar_title", "id", "android");
TextView abTitle = (TextView) findViewById(titleId);
abTitle.setTextColor(getResources().getColor(R.color.white));
DisplayMetrics metrics = new DisplayMetrics();
getWindowManager().getDefaultDisplay().getMetrics(metrics);
abTitle.setGravity(Gravity.CENTER);
abTitle.setWidth(metrics.widthPixels);
getActionBar().setTitle("I am center now");
代码示例来源:origin: stackoverflow.com
TableRow row;
TextView t1, t2;
int dip = (int) TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_DIP,(float) 1, getResources().getDisplayMetrics());
row = new TableRow(context);
row.setLayoutParams(new android.widget.TableRow.LayoutParams(android.widget.TableRow.LayoutParams.FILL_PARENT,
android.widget.TableRow.LayoutParams.WRAP_CONTENT));
t1 = new TextView(context);
t1.setTypeface(null, 1);
t1.setTextSize(15);
t1.setWidth(50 * dip);
t1.setPadding(20*dip, 0, 0, 0);
row.addView(t1);
代码示例来源:origin: tazimete/android-app-food-delivery-system
public void activateRiderProfile(){
btnProfileLoginTime.setBackgroundResource(R.drawable.bg_profile_item);
btnProfileLoginTime.setTextColor(Color.parseColor("#ffffff"));
btnProfileDuty.setBackgroundResource(R.drawable.bg_profile_item);
btnProfileDuty.setTextColor(Color.parseColor("#ffffff"));
btnProfileOrder.setBackgroundResource(R.drawable.bg_profile_item);
btnProfileOrder.setTextColor(Color.parseColor("#ffffff"));
btnProfileOrder.setWidth(400);
}
代码示例来源:origin: tazimete/android-app-food-delivery-system
public void inactiveRiderProfile(){
btnProfileLoginTime.setBackgroundResource(R.drawable.bg_profile_item_inactive);
btnProfileLoginTime.setTextColor(Color.parseColor("#514E4D"));
btnProfileDuty.setBackgroundResource(R.drawable.bg_profile_item_inactive);
btnProfileDuty.setTextColor(Color.parseColor("#514E4D"));
btnProfileOrder.setBackgroundResource(R.drawable.bg_profile_item_inactive);
btnProfileOrder.setTextColor(Color.parseColor("#514E4D"));
btnProfileOrder.setWidth(400);
}
代码示例来源:origin: stackoverflow.com
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
TextView myTextView = new TextView(this);
myTextView.setText("Marsha Jackson - (555) 555-5555 - marsha.jackson@email.com - www.jkl.com");
myTextView.setWidth(100);
myTextView.setHeight(500);
//you can keep adding code to change myTextView
setContentView(myTextView);
}
代码示例来源:origin: stackoverflow.com
TextView headerTextView = new TextView(this.context);
float scale = context.getResources().getDisplayMetrics().density;
if(scale > 2.0) {
headerTextView.setWidth(210);
headerTextView.setHeight(120);
headerTextView.setTextSize(17);
}
else {
headerTextView.setWidth(125);
headerTextView.setHeight(60);
headerTextView.setTextSize(21);
}
代码示例来源:origin: stackoverflow.com
private void setStyle(TextView textView, float weight) {
textView.setSingleLine(false);
textView.setWidth(0);
textView.setLayoutParams(new LayoutParams(LayoutParams.WRAP_CONTENT,
LayoutParams.WRAP_CONTENT, weight));
textView.setPadding(8, 0, 8, 0);
textView.setGravity(Gravity.CENTER_VERTICAL | Gravity.CENTER_HORIZONTAL);
}
代码示例来源:origin: stackoverflow.com
setContentView(R.layout.activity_main);
TextView numerator = (TextView) findViewById(R.id.firstBox);
TextView fractionBar = (TextView) findViewById(R.id.secondBox);
TextView denominator = (TextView) findViewById(R.id.thirdBox);
fractionBar.setWidth(denominator.getWidth());
代码示例来源:origin: stackoverflow.com
// On inflation, likely in Activity.onCreate()
final TextView v = (TextView) findViewById(R.id.myEditText);
v.addTextChangedListener(new TextWatcher() {
[...]
@Override
public void onTextChanged(CharSequence s, int start, int before, int count) {
float textSize = v.getPaint().measureText(s, start, start + count);
// onTextChanged may run on Ui Thread, but if it's not the case, the following statement must be called inside a Runnable posted to the main Looper.
v.setWidth(textSize); // Eventually, take some extra space for padding ?
}
});
代码示例来源:origin: Luolc/LiteSyllabusView
private void setName() {
tvName = new TextView(mContext);
tvName.setWidth(mSectionWidth);
tvName.setText(mData.getName());
tvName.setTextSize(mNameTextSize);
tvName.setTextColor(ContextCompat.getColor(mContext, R.color.textCourse));
tvName.setTypeface(Typeface.DEFAULT_BOLD);
addView(tvName);
}
代码示例来源:origin: Luolc/LiteSyllabusView
private void setPosition() {
tvPosition = new TextView(mContext);
tvPosition.setWidth(mSectionWidth);
tvPosition.setText("@" + mData.getPosition());
tvPosition.setTextSize(mPositionTextSize);
tvPosition.setTextColor(ContextCompat.getColor(mContext, R.color.textCourse));
addView(tvPosition);
}
代码示例来源:origin: Luolc/LiteSyllabusView
private void setNote() {
tvNote = new TextView(mContext);
tvNote.setWidth(mSectionWidth);
tvNote.setText("[" + mData.getNote() + "]");
tvNote.setTextSize(mNoteTextSize);
tvNote.setTextColor(ContextCompat.getColor(mContext, R.color.textCourse));
addView(tvNote);
}
代码示例来源:origin: stackoverflow.com
TextView tv1 = (TextView) findViewById(R.id.text1);
TextView tv2 = (TextView) findViewById(R.id.text2);
if(tv1.getWidth() < tv2.getWidth())
tv1.setWidth(tv2.getWidth());
else
tv2.setWidth(tv1.getWidth());
内容来源于网络,如有侵权,请联系作者删除!