android 颜色填充工具栏,Android工具栏颜色未由colorPrimary设置
根據谷歌文檔,我應該能夠在主題中使用colorPrimary設置工具欄背景的顏色,但它不起作用 . 這就是我所擁有的:
styles.xml:
@color/light_purple
@color/dark_purple
@color/dark_purple
@color/light_purple
活動布局:
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical"
tools:context=".MainActivity">
android:id="@+id/toolbar"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:minHeight="?attr/actionBarSize"
android:theme="@style/AppTheme"
tools:showIn="@layout/activity_main">
android:id="@+id/pivot_title_image"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:text="toolbar text view" />
...
活動:
public class MainActivity extends AppCompatActivity {
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar);
setSupportActionBar(toolbar);
}
我在清單中將我的應用主題設置為AppTheme: android:theme="@style/AppTheme" > 我在build.gradle中設置了android支持appcompat
compile 'com.android.support:appcompat-v7:22.1.0'
但是我的工具欄仍然沒有著色 . I know I can manually set the toolbar background color manually in the layout file ,但不應該從主題中獲得它的顏色?正如你所看到的強調顏色正在起作用 .
與50位技術專家面對面20年技術見證,附贈技術全景圖總結
以上是生活随笔為你收集整理的android 颜色填充工具栏,Android工具栏颜色未由colorPrimary设置的全部內容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: 求最大素数的c语言,for语句计算输出1
- 下一篇: android xml文件格式,andr