1

我注意到Android Studio上的Google模板在状态栏和工具栏之间有一点影子。我的平面设计师认为我不应该那样做,但我只是不知道,因为模板有它。材料设计应用程序需要状态栏和工具栏之间的阴影吗?

这样做的正确方法是什么?

下面是使用Android Studio模板和零代码修改创建的应用程序的两个屏幕截图。

enter image description here enter image description here

编辑:只是为了澄清,我知道这是因为这实际上是因为我的应用程序所需的我有一个导航抽屉<item name="android:statusBarColor">@android:color/transparent</item>发生。但我的问题不是如何解决它,我想知道这是否是谷歌希望它的工作方式?

另外我应该提到我只测试棒棒糖和棉花糖。

回答

1

不,它不应该在那里。状态栏应该平坦无阴影。只要看看这个页面:https://www.google.com/design/spec/style/color.html#color-color-schemes

enter image description here

这是我的透明的状态栏上运行棉花糖抽屉。影子不在那里。

enter image description here

主题:

<item name="android:windowTranslucentStatus">true</item> 
<item name="windowActionBar">false</item> 
<item name="windowNoTitle">true</item> 

我画采用改良ScrimInsetsFrameLayout彩色插图 - https://github.com/google/iosched/blob/master/android/src/main/java/com/google/samples/apps/iosched/ui/widget/ScrimInsetsFrameLayout.java


编辑

确切的说,这种布局构造从以下xml:

<carbon.widget.DrawerLayout xmlns:android="http://schemas.android.com/apk/res/android" 
          xmlns:app="http://schemas.android.com/apk/res-auto" 
          android:id="@+id/drawerLayout" 
          android:layout_width="match_parent" 
          android:layout_height="match_parent"> 

    <carbon.widget.LinearLayout 
     android:id="@+id/content" 
     android:layout_width="match_parent" 
     android:layout_height="match_parent" 
     android:fitsSystemWindows="true" 
     android:orientation="vertical" 
     app:carbon_insetColor="?attr/colorPrimary"/> 

    <carbon.widget.NavigationView 
     android:id="@+id/drawerMenu" 
     android:layout_width="240dp" 
     android:layout_height="match_parent" 
     android:layout_gravity="start" 
     android:background="?attr/carbon_colorBackground" 
     android:fitsSystemWindows="true" 
     android:orientation="vertical" 
     app:carbon_elevation="@dimen/carbon_elevationDrawer" 
     app:carbon_insetTop="0dp"/> 

</carbon.widget.DrawerLayout> 

它可以在这里找到完全开放代码一起:https://raw.githubusercontent.com/ZieIony/Carbon/master/samples/src/main/res/layout/activity_navigationview.xml

与插图的布局下推动其内容和插图上画的空间彩色矩形。这是内容布局。抽屉菜单具有与其根相似的布局,但其插入点设置为0dp,因此菜单可以占用所有的屏幕空间。标志是关键。

+0

所以你使用它作为你的主要活动布局的第一个视图? – casolorz

+0

我查看了io日程安排应用程序代码,我没有看到他们在哪里使用该框架布局,它也表示它已被弃用。我将它添加到直接从模板创建的新项目中,并将状态栏下的工具栏按下。 – casolorz

+0

正如我所说这是一个修改后的版本。 ScrimInsetsFrameLayout并不完美,但对我来说这是一个好的开始。它曾用于以前版本的Google应用程序。我在答案中增加了更多细节。我不想将碳添加到答案中,因为它太大而无法用作样本。 – Zielony

相关问题