2015-07-18 5 views
35

Ich habe versucht, den Schatten unter der Symbolleiste mit der Theme.AppCompat.Light.NoActionBar zu entfernen, mit jeder Empfehlung von Menschen, die jemals zuvor geantwortet haben, aber niemand hat gearbeitet. Ich habe versucht,wie Schatten unter Actionbar mit AppCompat.Light.NoActionBar entfernen?

<item name="android:windowContentOverlay">@null</item>  

und

<item name="android:windowContentOverlay">@drawable/solid_line</item> .... 

<shape xmlns:android="http://schemas.android.com/apk/res/android"android:shape="rectangle"> 
<solid android:color="@color/accueil_color" /> 
<size android:height="15dp" /> 
</shape> 

und mit diesem,

android:elevation="0dp" 

der Schatten vom oberen Rand des Bildschirms geht aber nicht verschwinden.

Haben Sie eine Idee, diese Schattenlinie vollständig zu entfernen ??

Antwort

73

Ich bin kein Experte, aber ich habe vor ein paar Stunden das gleiche Problem. Also die Idee hier ist, dass mit AppCompat wir die Bibliothek Attribute verwalten müssen, anstatt Android-Attribute. Mit anderen Worten, statt android: Höhen versuchen App: Höhe:

<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" /> 

</android.support.design.widget.AppBarLayout> 

EDIT:

Ich habe gerade versucht, eine andere Option ohne AppBarLayout. Dieser Weg funktioniert vollkommen in Ordnung für mich, der Schatten ist komplett weg. Also ich vermute das Problem ist in deiner anderen Ansicht. Ich glaube nicht, dass es Ihre ToolBar Tropfen den Schatten ist.

<android.support.v7.widget.Toolbar 
    xmlns:android="http://schemas.android.com/apk/res/android" 
    xmlns:app="http://schemas.android.com/apk/res-auto" 
    app:theme="@style/ThemeOverlay.AppCompat.Dark.ActionBar" 
    app:popupTheme="@style/ThemeOverlay.AppCompat.Light" 
    android:id="@+id/toolbar" 
    android:layout_width="match_parent" 
    android:layout_height="wrap_content" 
    android:minHeight="?attr/actionBarSize" 
    app:elevation="0dp" /> 
+0

Hum meine xml so ist, ich habe nicht android.support.design.widget.AppBarLayout, nur die Symbolleiste Widget, – user3607438

+0

Can not Kommentar zu deiner Antwort aufgrund von Karma). Meine beste Vermutung ist, dass Ihre erste Ansicht den Schatten und nicht die Symbolleiste verlässt. –

+0

Arf ... Ich habe versucht, Höhe in android.support.v7.widget.Toolbar ändern, und das ändert die Position des Schattens, ich denke, es ist nicht die Ursache ...:/ Sorry Das hat funktioniert : D denkt Wie man aufgelöst macht? – user3607438

1

@DmitryO Hum meine xml so ist, ich habe nicht android.support.design.widget.AppBarLayout, nur die Symbolleiste Widget,

<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" 
    xmlns:fab="http://schemas.android.com/apk/res-auto" 
    xmlns:materialdesign="http://schemas.android.com/apk/res-auto" 
    android:layout_width="match_parent" 
    android:layout_height="match_parent" 
    android:background="@color/white" 
    android:theme="@style/AppThemeAccueil"> 

    <View xmlns:android="http://schemas.android.com/apk/res/android" 
     android:layout_width="match_parent" 
     android:layout_height="@dimen/statusBarHeight" 
     android:background="@color/accueil_colorDark" 
     android:elevation="@dimen/statusBarElevation"/> 

    <android.support.v7.widget.Toolbar 
     xmlns:android="http://schemas.android.com/apk/res/android" 
     android:popupTheme="@style/AppThemeAccueilToolbar" 
     android:theme="@style/AppThemeAccueilToolbar" 
     android:id="@+id/toolbarAccueil" 
     android:layout_width="match_parent" 
     android:layout_height="wrap_content" 
     android:minHeight="?attr/actionBarSize" 
     materialdesign:elevation="0dp" 
     android:elevation="0dp" 
     android:outlineProvider="background" 
     android:layout_marginTop="@dimen/appBarTopMargin" > 

    </android.support.v7.widget.Toolbar> 
</RelativeLayout> 

Habe ich das gehabt? (Ich denke, das wird das Ergebnis nicht ändern)

64

Verwendung app:elevation="0dp" instead of android:elevation

+7

Das funktioniert. Ich habe es nur im AppBarLayout eingefügt. –

+6

Das macht den Titel und die Tasten verschwinden für mich ... – dChimento

+0

ja, wenn es appcomapt Thema ist –

43

Ich hatte das gleiche Problem. Die Anwendung app:elevation="0dp" auf android.support.design.widget.AppBarLayout löst das Problem

+0

danke für die wunderbare Antwort !! – Pankaj

+0

Richtige Antwort. Vielen Dank! –

+0

vielen Dank es funktionierte wie ein Charme –

16

hinzufügen app:elevation="0dp" in AppBarLayout und Schatten wird auszublenden sein.

+0

nicht vergessen findViewById (R.id.appBar) .bringToFront(); https://stackoverflow.com/a/41931318/2736039 –

4

Verwenden Sie einfach nach dem super.onCreate(savedInstanceState);

if(getSupportActionBar() != null) 
{ 
    getSupportActionBar().setElevation(0); 
} 
1

einfach Ihre AppBarLayout setzen innerhalb eines LinearLayout an einem separaten XML-Datei, und dann, um diesen XML in Ihre Haupt-XML.

6

Ich hatte das gleiche Problem.

Falls in Ihrer Toolbar ist innerhalb android.support.design.widget.AppBarLayout Hinzufügen App: Höhe = "0DP" auf android.support.design.widget.AppBarLayout wird Ihr Problem lösen.

Else app:elevation="0dp" auf Toolbar hinzufügen.

<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" /> 

Hoffe, es hilft :)

Verwandte Themen