0

私は透明なアクションバーを開発しなければなりませんでした。 いくつかの調査の後、私はLG2デバイスでのみ希望の結果を達成することができました。 私はLG3上でコードを実行すると動作しません(アクションバーは透明ではありません)。透明なアクションバー

私のスタイルのフォルダがどのように見えるかです:

<resources> 
<!-- Base application theme. --> 
<style name="AppTheme" parent="Theme.AppCompat.Light"> 
     <item name="android:itemBackground">@color/black</item> 
     <item name="android:textColor">@color/white</item> 
    </style> 

    <style name="AppTheme.ActionBar.Transparent" parent="AppTheme"> 
     <item name="android:windowContentOverlay">@null</item> 
     <item name="windowActionBarOverlay">true</item> 
     <item name="colorPrimary">@android:color/transparent</item> 
    </style> 

    </resources> 

誰かがこの問題を解決する方法の提案を持っていますか?

+0

このrefを確認してください。参考のためにhttp://stackoverflow.com/questions/37019028/need-fully-transparent-status-bar/37019100#37019100 @sollo –

+0

@DaminiMehra TNXを。私は以下の答えで私の問題を解決しました。 – sollo

答えて

3

actionbarのスタイルを定義するだけで済みます。ツールバーを使用して、その色を透明に設定します。

<!-- Your App Theme --> 

    <style name="MyMaterialTheme.Base" parent="Theme.AppCompat.Light.DarkActionBar"> 
      <item name="windowNoTitle">true</item> 
      <item name="windowActionBar">false</item> 
      <item name="colorPrimary">@color/colorPrimary</item> 
      <item name="colorPrimaryDark">@color/colorPrimaryDark</item> 
      <item name="colorAccent">@color/colorAccent</item> 
     </style> 

<!-- Your custom ActionBar Style --> 

<style name="CustomActionBar" parent="@style/MyMaterialTheme.Base"> 
    <item name="android:windowActionBarOverlay">true</item> 
    <!-- Support library compatibility --> 
    <item name="windowActionBarOverlay">true</item> 
</style> 

あなた `

toolbar.xml

<android.support.v7.widget.Toolbar 
    xmlns:android="http://schemas.android.com/apk/res/android" 
    xmlns:app="http://schemas.android.com/apk/res-auto" 
    android:id="@+id/toolbar" 
    android:layout_width="match_parent" 
    android:layout_height="wrap_content" 
    app:theme="@style/CustomActionBar"/> 

任意のレイアウトで、このtoolbarを使用してください。

<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" 
    android:layout_width="match_parent" 
    android:layout_height="match_parent"> 

    <!-- Toolbar should be above content--> 
    <include layout="@layout/toolbar" /> 

</RelativeLayout> 

`

+0

こんにちは、申し訳ありませんが、私の遅すぎる返信のために。その助けてくれました。 – sollo