【问题标题】:Android elevation not there throughout whole app整个应用程序中不存在 Android 海拔高度
【发布时间】:2019-06-15 04:27:10
【问题描述】:

我的 Android 应用程序有问题:海拔在整个应用程序中都不起作用。我的 CardViews 没有升高,我的 Toolbars 没有这个小高度,你也看不到我的 BottomNavigationView 的边缘,因为它是白色的并且没有效果,所以没有线条。

你有什么线索吗,为什么会这样?我已经对此进行了谷歌搜索,但我从未发现任何影响整个应用程序的内容。如果您需要更多信息,请询问,我很乐意提供。

一些(也许)重要的细节 - 我所有的活动和片段都使用“AppTheme.NoActionBar”

非常感谢您的任何建议

我的样式.xml:

<resources>

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

<style name="AppTheme.NoActionBar">
    <item name="windowActionBar">false</item>
    <item name="windowNoTitle">true</item>

    <item name="colorPrimary">@color/colorPrimary</item>
    <item name="colorPrimaryDark">@color/colorPrimaryDark</item>
    <item name="colorAccent">@color/colorAccent</item>
</style>

<style name="AppTheme.AppBarOverlay" parent="ThemeOverlay.AppCompat.Dark.ActionBar" />

<style name="AppTheme.PopupOverlay" parent="ThemeOverlay.AppCompat" />

<style name="AppTheme.NoActionBar.AppBarOverlay" parent="ThemeOverlay.AppCompat.Dark.ActionBar" />

<style name="AppTheme.NoActionBar.PopupOverlay" parent="ThemeOverlay.AppCompat.Light" />

<style name="AppTheme.BottomSheetDialog" parent="Theme.Design.Light.BottomSheetDialog">
    <item name="bottomSheetStyle">@style/AppTheme.BottomSheetStyle</item>
</style>

<style name="AppTheme.BottomSheetStyle" parent="Widget.Design.BottomSheet.Modal">
    <item name="behavior_hideable">true</item>
    <item name="behavior_skipCollapsed">true</item>
</style>

<!--<style name="myDialog" parent="Theme.AppCompat.Light.Dialog">
    <item name="android:windowNoTitle">true</item>
</style>-->



<!-- added from new -->
<style name="SplashTheme" parent="Theme.AppCompat.NoActionBar">
    <item name="android:windowBackground">@drawable/splash_background</item>
</style>

<style name="CardView.Round" parent="Base.CardView">
    <item name="cardCornerRadius">10dp</item>
    <item name="cardElevation">3dp</item>
</style>

<style name="Borderless.Button.Accent" parent = "Borderless.Button">
    <item name="android:textColor">@color/colorAccent</item>

</style>

<style name="Borderless.Button" parent="Widget.AppCompat.Button.Borderless">
    <item name="android:textStyle">bold</item>
    <item name="android:textSize">18sp</item>
</style>

【问题讨论】:

  • 您是否在装有 Android 5 或更高版本的设备上进行测试?
  • @TheWanderer 是的,但我已经找到了解决方案

标签: android android-layout android-theme android-styles android-elevation


【解决方案1】:

您需要在 AndroidManifest.xml 文件中设置android:hardwareAccelerated="true" 属性

【讨论】:

    猜你喜欢
    • 2014-12-30
    • 1970-01-01
    • 2011-06-19
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2018-10-03
    • 1970-01-01
    相关资源
    最近更新 更多