有没有办法以编程方式设置textStyle属性TextView?似乎没有一种setTextStyle()方法.
要清楚,我不是在谈论View/Widget样式!我在谈论以下内容:
<TextView
android:id="@+id/my_text"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:text="Hello World"
android:textStyle="bold" />
Run Code Online (Sandbox Code Playgroud) 我正在尝试动态创建TableRow对象并将其添加到TableLayout.该TableRow对象有2个项目,一个TextView和CheckBox.该TextView项目需要有自己的布局权重设置为1,以推动CheckBox项目的最右边.
我找不到有关如何以编程方式设置项目的布局权重的文档TextView.
我想用Widget.MaterialComponents.TextInputLayout.OutlinedBox样式创建TextInputLayout.我尝试了很多方法,但无法获得所需的结果.这是我的代码.
TextInputLayout textInputLayout = new TextInputLayout(getActivity(),null,R.style.Widget_MaterialComponents_TextInputLayout_OutlinedBox);
textInputLayout.setHint("My Hint");
TextInputEditText editText = new TextInputEditText(textInputLayout.getContext());
textInputLayout.addView(editText);
parentView.addView(textInputLayout);
Run Code Online (Sandbox Code Playgroud)
我也尝试过:
TextInputLayout textInputLayout = new TextInputLayout(getActivity(),null,TextInputLayout.BOX_BACKGROUND_OUTLINE);
Run Code Online (Sandbox Code Playgroud)
android android-layout android-styles material-design textinputlayout