【问题标题】:Android Material design customizingAndroid 材料设计定制
【发布时间】:2015-07-02 09:39:37
【问题描述】:

请快速提问。 我刚刚遵循了一个教程,其中解释了如何在使用 Material Design 时更改工具栏和系统栏的颜色。 当在 v21/styles.xml 中使用新颜色时,他们将它们称为 colorPrimary 和 colorPrimaryDark,所以我得出结论第一个是工具栏,第二个是系统栏。我相信这是正确的,就好像我用另一个名字替换其中一个,Android 尖叫。 还有更多我们可以定制的东西吗?是否有这些物品的列表以及它们的名字?我一直在环顾四周,但到目前为止还没有成功 干杯

【问题讨论】:

    标签: android customization material-design


    【解决方案1】:

    你可能想看看这个像here。它为您提供了所有可用参数的列表。

    如果你使用的是AppCompat,只要使用不带android前缀的属性,所以

    <item name="android:colorPrimary">@color/primary</item>
    

    将被替换为

    <item name="colorPrimary">@color/primary</item>
    

    【讨论】:

      【解决方案2】:

      你以这种方式跟随 在 VALUES v21 中


      style.xml

       <style name="AppTheme" parent="AppTheme.Base">
          <!-- Customize your theme here. -->
      </style>
      

      价值 样式.xml

       <!-- Base application theme. -->
      <style name="AppTheme" parent="AppTheme.Base">
          <!-- Customize your theme here. -->
      </style>
      <style name="AppTheme.Base" parent="Theme.AppCompat.Light.NoActionBar">
          <item name="colorPrimary">@color/ColorPrimary</item>
          <item name="colorPrimaryDark">@color/ColorPrimaryDark</item>
      
      </style>
      

      颜色.xml

              <color name="ColorPrimary">#ffffff</color>
              <color name="ColorPrimaryDark">#d1d1d1</color>
      

      在布局中

      activity_main

      添加这个

       <android.support.v7.widget.Toolbar xmlns:android="http://schemas.android.com/apk/res/android"
          android:layout_width="match_parent"
          android:layout_height="wrap_content"
          android:background="@color/ColorPrimary"
          android:id="@+id/actionbar"
          android:theme="@style/ThemeOverlay.AppCompat.Light"
          android:elevation="4dp">
      </android.support.v7.widget.Toolbar>
      

      最后一步是在 Activity.java 中添加这一行

       // calling android.support.v7.widget.Toolbar in ActionBar
          setSupportActionBar((Toolbar) findViewById(R.id.actionbar));
      

      【讨论】:

        猜你喜欢
        • 2017-10-06
        • 2014-09-19
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        相关资源
        最近更新 更多