2017-07-28 3 views
0

(私は、インターネットからこの例を持っている)アンドロイド:私はこのツールバーは、影を落とす理由NestedScrollViewがある場合にのみ、お知りになりたいツールバー標高/シャドウ

<android.support.design.widget.CoordinatorLayout 
    xmlns:android="http://schemas.android.com/apk/res/android" 
    xmlns:app="http://schemas.android.com/apk/res-auto" 
    android:layout_width="match_parent" 
    android:layout_height="match_parent"> 

    <android.support.v4.widget.NestedScrollView 
     android:layout_width="match_parent" 
     android:layout_height="match_parent" 
     app:layout_behavior="@string/appbar_scrolling_view_behavior"> 

     <!-- Your scrolling content --> 

    </android.support.v4.widget.NestedScrollView> 

    <android.support.design.widget.AppBarLayout 
     android:layout_height="wrap_content" 
     android:layout_width="match_parent"> 

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

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

(NestedScrollViewなし)このツールバー

<android.support.design.widget.CoordinatorLayout 
    xmlns:android="http://schemas.android.com/apk/res/android" 
    xmlns:app="http://schemas.android.com/apk/res-auto" 
    android:layout_width="match_parent" 
    android:layout_height="match_parent"> 

    <android.support.design.widget.AppBarLayout 
     android:layout_height="wrap_content" 
     android:layout_width="match_parent"> 

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

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

私は必要に応じて写真を投稿できますが、なぜこのようなことが起こるのかわかりません。 これは私がこれまで試したものです:

clipToPadding =親リニアレイアウト
  • の「偽」を手動で設定する標高(私のデバイスが事前ロリポップではありません)
  • 「= outlineProvider SETINGを設定
    • 「アンドロイドの設定ビュー上
    • :hardwareAccelerated = 『境界のAndroidManifest.xml

    編集の』真:私はタグを使用して、それを解決してきました。コードで私の答えをチェックしてください。

  • +0

    達成したい写真とあなたのコードで何を得ているのかを投稿してください。私はあなたを助ける。 –

    +1

    @AmrishKakadiya私の返信を読む、私はすでにそれを修正することができたが、とにかく写真を投稿することができます。あなたの助けを提供してくれてありがとう:D –

    +0

    素晴らしい、画像を投稿する必要はありません。 –

    答えて

    0

    ちょっと調べてみると、マージタグがこのトリックを行うことがわかりました。このタグは、親レイアウト内のtoolbar.xmlをマージして、z-orderingを処理し、意図した場所にツールバーを配置します。

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

    そして、いや、ここに尋ねると、私はここに投稿した後、時間足らずでこのタグを見つけることだけで幸運だった、私がした最初のものではありませんでした。とにかく、ここに私の解決策です。

    関連する問題