问题
I have created an app using Android Studio 2.3.3, choosing Empty Activity Template. After its creation I went and changed the background color to something like colorAccent and I also changed the colorPrimary to colorAccent in colors.xml.
Now, when I ran the app, following emulator display appeared.
As you can see, it displays my app name, followed by a dark line. I don't understand where this dark line has come from and how can I get rid of this?
However, this dark line does not appear in Android Studio design mode (see screenshot below).
回答1:
it is shadow of action bar my friend to remove this shadow add below lines to your theme under res/values/style
<style name="MYTheme" parent="android:Theme.Holo.Light">
<item name="colorPrimary">@color/colorWhite</item>
<item name="colorPrimaryDark">@color/colorWhite</item>
<item name="colorAccent">@color/colorAccent</item>
<item name="windowContentOverlay">@null</item>
<item name="android:windowContentOverlay">@null</item>
</style>
now add this in manifest file this to your activity
<activity
android:name=".YourActivity"
android:theme="@style/MYTheme"/>
or try this
getSupportActionBar().setElevation(0);
来源:https://stackoverflow.com/questions/45033408/android-app-masthead-display