相关疑难解决方法(0)

android在代码中设置样式

我正在尝试使用像这样的样式的TextView构造函数:

TextView myText = new TextView(MyActivity.this, null, R.style.my_style );

但是,当我这样做时,文本视图似乎不采用样式(我通过在静态对象上设置它来验证样式).

我也尝试过使用myText.setTextAppearance(MyActivity.this, R.style.my_style)但它也不起作用

android coding-style textview

243
推荐指数
6
解决办法
19万
查看次数

Android:以编程方式设置视图样式

这是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编程方式设置属性?

android android-layout

202
推荐指数
9
解决办法
23万
查看次数

AppCompatActivity.onCreate只能在同一个库组中调用

升级到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 android-appcompat android-lint

94
推荐指数
3
解决办法
4万
查看次数

以编程方式设置TextInputLayout主题

有没有一种方法可以在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"编程方式将此行更改为另一个主题吗?

xml android android-layout android-textinputlayout

6
推荐指数
1
解决办法
2319
查看次数