How to remove android

I am using Android Studio for programming. The target SDK is 23 and the minimum SDK is 15

I am trying to remove the shadow between my action bar and my sliding tab. But I can not.

Note. The shadow is visible only on Android 5 and at the top.

I used <item name="elevation">0dp</item> and getSupportActionBar().setElevation(0); But still it doesn't work ...

enter image description here

My style.xml

 <resources> <!-- Base application theme. --> <style name="AppTheme" parent="Theme.AppCompat.Light"> <!-- 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> </style> <style name="AppTheme.AppBarOverlay" parent="ThemeOverlay.AppCompat.Dark.ActionBar" /> <style name="AppTheme.PopupOverlay" parent="ThemeOverlay.AppCompat.Light"> <item name="elevation">0dp</item> </style> 

My style is V21

 <resources>> <style name="AppTheme.NoActionBar"> <item name="windowActionBar">false</item> <item name="windowNoTitle">true</item> <item name="android:windowDrawsSystemBarBackgrounds">true</item> <item name="android:statusBarColor">@android:color/transparent</item> </style> 

My MainActivity.java onCreateCode:

  @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_main); Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar); setSupportActionBar(toolbar); getSupportActionBar().setElevation(0); 

....

+5
source share
2 answers

You are missing a prefix in your style.

 <item name="android:elevation">0dp</item> 

Having said that, you can also install it directly on your AppBarLayout

 <android.support.design.widget.AppBarLayout android:layout_height="wrap_content" android:layout_width="match_parent" android:elevation="0dp" android:theme="@style/AppTheme.AppBarOverlay"> 

Or what I like to do is move the SlidingTabLayout to the AppBarLayout so that a shadow appears under it:

 <android.support.design.widget.AppBarLayout android:layout_height="wrap_content" android:layout_width="match_parent" android:theme="@style/AppTheme.AppBarOverlay"> <android.support.v7.widget.Toolbar android:id="@+id/toolbar" android:layout_width="match_parent" android:layout_height="?attr/actionBarSize" android:background="?attr/colorPrimary" app:popupTheme="@style/AppTheme.PopupOverlay" /> <com.ccswe.SmokingLog.views.widgets.SlidingTabLayout android:id="@+id/sliding_tabs" android:layout_width="wrap_content" android:layout_height="@dimen/tab_layout_height" /> </android.support.design.widget.AppBarLayout> 

Exit the last code snippet

+9
source

Try adding a mark to 0 using the support library

 <android.support.design.widget.AppBarLayout android:layout_width="match_parent" android:layout_height="wrap_content" app:elevation="0dp" android:theme="@style/AppTheme.AppBarOverlay"> 
+3
source

Source: https://habr.com/ru/post/1238870/


All Articles