Programming

작업 표시 줄 아래의 그림자 제거

procodes 2020. 5. 8. 21:33
반응형

작업 표시 줄 아래의 그림자 제거


나는 actionbarsherlock을 사용합니다. 아래 코드는 배경을 사용자 정의 배경으로 변경하는 역할을합니다.

<style name="Widget.Styled.ActionBar" parent="Widget.Sherlock.ActionBar">
    <item name="background">@drawable/actionbar_bg</item>
    <item name="android:background">@drawable/actionbar_bg</item>
    <...>  
</style>

<style name="Theme.MyApp" parent="@style/Theme.Sherlock.Light">
    <item name="actionBarStyle">@style/Widget.Styled.ActionBar</item>
    <item name="android:actionBarStyle">@style/Widget.Styled.ActionBar</item>
    <..>
</style>

그리고 actionbarsherlock (허니컴 아래 버전)에서 작동합니다. 그러나 ICS에서는 원하지 않는 작업 표시 줄 아래에 그림자가 있습니다. 사라지게하는 스타일 아이템은 무엇입니까?


사라지게하는 스타일 아이템은 무엇입니까?

그림자를 제거하려면 앱 테마에 다음을 추가하십시오.

<style name="MyAppTheme" parent="android:Theme.Holo.Light">
    <item name="android:windowContentOverlay">@null</item>
</style>

업데이트 : @ Quinny898에서 언급했듯이 Android 5.0에서 변경된 사항이므로 setElevation(0)작업 표시 줄 을 호출 해야합니다. 지원 라이브러리를 사용하는 경우 다음과 같이 지원 라이브러리를 호출해야합니다.

getSupportActionBar().setElevation(0);

Android 5.0의 경우 스타일 사용으로 직접 설정하려면 다음을 수행하십시오.

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

지원 라이브러리 호환성을 위해 :

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

AppCompat 라이트 테마의 스타일 예 :

<style name="Theme.MyApp.ActionBar" parent="@style/Widget.AppCompat.Light.ActionBar.Solid.Inverse">
    <!-- remove shadow below action bar -->
    <!-- <item name="android:elevation">0dp</item> -->
    <!-- Support library compatibility -->
    <item name="elevation">0dp</item>
</style>

그런 다음이 사용자 정의 ActionBar 스타일을 앱 테마에 적용하십시오.

<style name="Theme.MyApp" parent="Theme.AppCompat.Light">
    <item name="actionBarStyle">@style/Theme.MyApp.ActionBar</item>
</style>

5.0 이전 Android의 경우이를 앱 테마에도 추가하십시오.

<!-- Remove shadow below action bar Android < 5.0 -->
<item name="android:windowContentOverlay">@null</item>

Android 5.0에서는 이것이 변경되었으므로 작업 표시 줄에서 setElevation (0)을 호출해야합니다. 지원 라이브러리를 사용하는 경우 다음과 같이 지원 라이브러리를 호출해야합니다.

getSupportActionBar().setElevation(0);

windowContentOverlay 스타일 항목의 영향을받지 않으므로 스타일을 변경할 필요가 없습니다.


app:elevation="0dp"앱 바에 그림자를 숨기려면 AppBarLayout에 추가


ActionBarSherlock으로 작업중인 경우

당신의 테마에 이것을 추가하십시오 :

<style name="MyTheme" parent="Theme.Sherlock">
    ....
    <item name="windowContentOverlay">@null</item>
    <item name="android:windowContentOverlay">@null</item>
    ....
</style>

android.support.design.widget.AppBarLayout에서 app : elevetor = "0dp"를 설정해야 작동합니다.

<android.support.design.widget.AppBarLayout
    app:elevation="0dp"... >

    <android.support.v7.widget.Toolbar
        android:id="@+id/toolbar"
        android:layout_width="match_parent"
        android:layout_height="?attr/actionBarSize"
        android:background="@android:color/transparent"
        app:popupTheme="@style/AppTheme.PopupOverlay" >


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

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

app:elevation="0dp" 

하지만

android:elevation="0dp"

안드로이드 L에서 나를 위해 일했습니다.


나는이 같은 문제가 있으며이 문제를 성공적으로 해결했습니다. 표고를 제거하려는 활동에서 표고를 0 부동 소수점 값으로 변경하기 만하면됩니다.

If you want to change it in an activity called MyActivity.java so you have to get the ActionBar first.

First import the ActionBar class

import android.support.v7.app.ActionBar;

after importing you have to initialize a variable of action bar and set its elevation to 0.

 private ActionBar toolbar;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
    .
    .
    toolbar=getSupportActionBar();
    toolbar.setElevation(0);
    .
    .
    }

For Xamarin Developers, please use : SupportActionBar.Elevation = 0; for AppCompatActivity or ActionBar.Elevation = 0; for non-compat Activities


Try This it helped me without changing theme . Put Your AppBarLayout inside any layout.Hope this will help you

<RelativeLayout
    android:layout_width="match_parent"
    android:layout_height="wrap_content">
<android.support.design.widget.AppBarLayout
    android:id="@+id/app_bar"
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    android:fitsSystemWindows="false"
    android:theme="@style/ThemeOverlay.AppCompat.Dark.ActionBar">


    <android.support.v7.widget.Toolbar
        android:id="@+id/toolbar"
        android:layout_width="match_parent"
        app:popupTheme="@style/ThemeOverlay.AppCompat.Light"
        android:layout_height="?attr/actionBarSize"
       android:background="@color/white">
        <ImageView
            android:src="@drawable/go_grocery_logo"
            android:layout_width="108dp"
            android:layout_height="32dp" />
    </android.support.v7.widget.Toolbar>


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

For those working on fragments and it disappeared after setting toolbar.getBackground().setAlpha(0); or any disappearance, i think you have to bring your AppBarLayout to the last in the xml, so its Fragment then AppBarLayout then relativelayout/constraint/linear whichever u use.


Solution for Kotlin (Android 3.3, Kotlin 1.3.20)

override fun onCreate(savedInstanceState: Bundle?) {
    super.onCreate(savedInstanceState)
    supportActionBar!!.elevation = 0f
}

참고URL : https://stackoverflow.com/questions/12246388/remove-shadow-below-actionbar

반응형