是否可以通過編程方式將Widget.AppCompat.Button主題應用於按鈕?以編程方式將主題應用到按鈕
Button button = new Button(context);
button.setText("Button");
目前,我使用的是試圖實現像程序兼容性主題風格的自定義繪製資源,但我認爲這可能是更容易實現。
在佈局它實現這樣的:提前
<Button
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:theme="@style/ThemeBasedOnAppcompatButton"/>
感謝。
謝謝!我想我的方法來實現動態佈局是錯誤的。我會用listview適配器替換它。 –