我正在尝试使用像这样的样式的TextView构造函数:
TextView myText = new TextView(MyActivity.this, null, R.style.my_style );
但是,当我这样做时,文本视图似乎不采用样式(我通过在静态对象上设置它来验证样式).
我也尝试过使用myText.setTextAppearance(MyActivity.this, R.style.my_style)
但它也不起作用
这是XML:
<RelativeLayout
xmlns:android="http://schemas.android.com/apk/res/android"
style="@style/LightStyle"
android:layout_width="fill_parent"
android:layout_height="55dip"
android:clickable="true"
android:orientation="horizontal" >
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="horizontal" />
</RelativeLayout>
Run Code Online (Sandbox Code Playgroud)
如何以style
编程方式设置属性?
升级到appcompat后,25.1.0
我开始收到有线错误.
在我的代码中:
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
Run Code Online (Sandbox Code Playgroud)
我得到lint错误:
AppCompatActivity.onCreate can only be called from within the same library group (groupId=com.android.support)
如何防止这种行为?
有没有一种方法可以在Android中以编程方式更改TextInputLayout的主题。如果我有以下TextInputLayout例如:
<android.support.design.widget.TextInputLayout
android:id="@+id/label"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_gravity="bottom"
android:paddingTop="16dp"
android:theme="@style/TextInputLayoutTheme"
app:errorTextAppearance="@style/Error">
<android.support.v7.widget.AppCompatEditText
android:id="@+id/edit_text"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:paddingBottom="8dp"
android:paddingTop="8dp"/>
</android.support.design.widget.TextInputLayout>
Run Code Online (Sandbox Code Playgroud)
我可以以android:theme="@style/TextInputLayoutTheme"
编程方式将此行更改为另一个主题吗?