我已經爲TextView的contentBg風格定義了紅色。我是否可以通過更改或重命名父級樣式中的樣式名稱myContentNew將TextView顏色更改爲藍色? TextView樣式name-contentBG不應該改變。在Android系統中可能嗎?繼承Android風格
<RelativeLayout
style="@style/myContent"
android:layout_width="fill_parent"
android:layout_height="wrap_content">
<TextView
style="@style/contentBG"
android:layout_width="fill_parent"
android:layout_height="fill_parent"/>
</RelativeLayout>
我的代碼應該像下面
<RelativeLayout
style="@style/myContentNew"
android:layout_width="fill_parent"
android:layout_height="wrap_content">
<TextView
style="@style/contentBG"
android:layout_width="fill_parent"
android:layout_height="fill_parent"/>
</RelativeLayout>
你可以得到明確的想法與我的附加的圖像。
像CSS:
.myContent .contentBg{background-color:red}
.myContentNew .contentBg{background-color:blue}
感謝
似乎你試着建立一個主題吧?你需要在一種佈局還是所有佈局中做到這一點? –
其實我想用這個作爲主動或非主動狀態與上述要求 –
我不認爲你可以直接設置這種類型的繼承。我看到的唯一方法是設置2個主題並使用樣式作爲引用,這些引用將根據所選主題進行更改。 –