我不能删除AppBarLayout下面的阴影,我用下面的代码删除AppBarLayout下面阴影
应用:在这两个AppBarLayout和工具栏海拔=“0dp”
,但它不是为我工作。任何人都可以帮助我解决这个问题。
我不能删除AppBarLayout下面的阴影,我用下面的代码删除AppBarLayout下面阴影
应用:在这两个AppBarLayout和工具栏海拔=“0dp”
,但它不是为我工作。任何人都可以帮助我解决这个问题。
你应该为工具栏设置高度为0
<android.support.design.widget.AppBarLayout
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:id="@+id/appbar"
android:layout_width="match_parent"
android:layout_height="?attr/actionBarSize"
android:theme="@style/ThemeOverlay.AppCompat.Dark.ActionBar"
android:fitsSystemWindows="true"
app:elevation="0dp">
<android.support.v7.widget.Toolbar
xmlns:app="http://schemas.android.com/apk/res-auto"
android:id="@+id/toolbar"
android:layout_width="match_parent"
android:layout_height="match_parent"
app:popupTheme="@style/ThemeOverlay.AppCompat.Light"
app:elevation="0dp" />
</android.support.design.widget.AppBarLayout>
我相信这个问题是指向同一个问题的Android appbarlayout抬高出现在状态栏中
可能的解决方案: 你的根布局应具备的android :fitsSystemWindows =“true”,否则你的UI不会在状态栏后面绘制。
现在包裹AppBarLayout另一CoordinatorLayout具有
android:fitsSystemWindows="false".
这将防止阴影溢出到状态栏里面。
或 添加海拔0dp到AppBarLayout
<android.support.design.widget.AppBarLayout
android:id="@+id/app_bar_layout"
android:layout_width="match_parent"
android:layout_height="wrap_content"
app:elevation="0dp">
添加一个id AppBarLayout。例如android:id=“@+id/mAppBarLayout”
您的活动内(例如MainActivity.java)接收机类
创建一个新变量
private AppBarLayout mAppBarLayout;
内onCreate方法添加以下线 -
mAppBarLayout=(AppBarLayout)findViewById(R.id.mAppBarLayout);
现在,添加以下行去除海拔 -
mAppBarLayout.setElevation(0);
/
您可以设置自己的活动样式这样的:
<!-- Your main theme with ActionBar shadow. -->
<style name="MyAppTheme" parent="android:Theme.Holo.Light">
....
</style>
<!-- Theme without ActionBar shadow (inherits main theme) -->
<style name="MyNoActionBarShadowTheme" parent="MyAppTheme">
<item name="windowContentOverlay">@null</item>
<item name="android:windowContentOverlay">@null</item>
</style>
所以的Manifest.xml可以为所有活动设置不同的风格:
<!-- Activity with ActionBar shadow -->
<activity
android:name=".ShadowActivity"
android:theme="@style/MyAppTheme"/>
<!-- Activity without ActionBar shadow -->
<activity
android:name=".NoShadowActivity"
android:theme="@style/MyNoActionBarShadowTheme"/>
或者你也可以设置编程右主题在onCreate()方法:
@Override
protected void onCreate(Bundle savedInstanceState) {
setTheme(R.style.MyNoActionBarShadowTheme);
super.onCreate(savedInstanceState);
//...
}
样品CDE ...... – nzala
集应用程式:ELE vation =“0dp” – nzala
namespace xmlns:app =“http://schemas.android.com/apk/res-auto”而不是android一个 – nzala