本文整理汇总了Java中android.widget.EditText.setWidth方法的典型用法代码示例。如果您正苦于以下问题:Java EditText.setWidth方法的具体用法?Java EditText.setWidth怎么用?Java EditText.setWidth使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类android.widget.EditText
的用法示例。
在下文中一共展示了EditText.setWidth方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: newStep
import android.widget.EditText; //导入方法依赖的package包/类
private LinearLayout newStep(int labelId, String autofillHints) {
LinearLayout layout = new LinearLayout(this);
layout.setOrientation(LinearLayout.HORIZONTAL);
TextView label = new TextView(this);
label.setText(labelId);
layout.addView(label);
EditText input = new EditText(this);
input.setAutofillHints(autofillHints);
input.setWidth(500); // TODO: proper size
layout.addView(input);
return layout;
}
示例2: onCreateView
import android.widget.EditText; //导入方法依赖的package包/类
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container,
Bundle savedInstanceState) {
View V = inflater.inflate(R.layout.fragment_edit, container, false);
CardView cardView = (CardView) V.findViewById(R.id.EditMatrixCard);
SharedPreferences sharedPreferences = PreferenceManager.getDefaultSharedPreferences(getContext());
String string = sharedPreferences.getString("ELEVATE_AMOUNT", "4");
String string2 = sharedPreferences.getString("CARD_CHANGE_KEY", "#bdbdbd");
cardView.setCardElevation(Integer.parseInt(string));
cardView.setCardBackgroundColor(Color.parseColor(string2));
CardView.LayoutParams params1 = new CardView.LayoutParams(ViewGroup.LayoutParams.WRAP_CONTENT,
ViewGroup.LayoutParams.WRAP_CONTENT);
int index = getArguments().getInt("INDEX");
Matrix m = ((GlobalValues) getActivity().getApplication()).GetCompleteList().get(index);
GridLayout gridLayout = new GridLayout(getContext());
gridLayout.setRowCount(m.GetRow());
gridLayout.setColumnCount(m.GetCol());
for (int i = 0; i < m.GetRow(); i++) {
for (int j = 0; j < m.GetCol(); j++) {
EditText editText = new EditText(getContext());
editText.setId(i * 10 + j);
editText.setGravity(Gravity.CENTER);
if (!PreferenceManager.getDefaultSharedPreferences(getContext()).getBoolean("DECIMAL_USE", true)) {
editText.setInputType(InputType.TYPE_CLASS_NUMBER
| InputType.TYPE_NUMBER_FLAG_SIGNED);
} else {
editText.setInputType(InputType.TYPE_CLASS_NUMBER | InputType.TYPE_NUMBER_FLAG_DECIMAL
| InputType.TYPE_NUMBER_FLAG_SIGNED);
}
editText.setFilters(new InputFilter[]{new InputFilter.LengthFilter(getLength())});
if (!PreferenceManager.getDefaultSharedPreferences(getContext()).getBoolean("SMART_FIT_KEY", false)) {
editText.setWidth(ConvertTopx(62));
editText.setTextSize(SizeReturner(3, 3, PreferenceManager.getDefaultSharedPreferences(getContext()).
getBoolean("EXTRA_SMALL_FONT", false)));
} else {
editText.setWidth(ConvertTopx(CalculatedWidth(m.GetCol())));
editText.setTextSize(SizeReturner(m.GetRow(), m.GetCol(),
PreferenceManager.getDefaultSharedPreferences(getContext()).
getBoolean("EXTRA_SMALL_FONT", false)));
}
editText.setText(SafeSubString(GetText(m.GetElementof(i, j)), getLength()));
editText.setSingleLine();
GridLayout.Spec Row = GridLayout.spec(i, 1);
GridLayout.Spec Col = GridLayout.spec(j, 1);
GridLayout.LayoutParams params = new GridLayout.LayoutParams(Row, Col);
gridLayout.addView(editText, params);
}
}
gridLayout.setLayoutParams(params1);
cardView.addView(gridLayout);
RootView = V;
return V;
}