0

tablayoutの後にドロップシャドウを作成しようとしていますが、別のタブをクリックした直後に表示されません。私はそれをスクロールした後に何が起こるのですか。タブラウトドロップシャドーは、Android LOLipopopの別のタブをクリックすると消えます。

ドロップシャドウは、最初のロード後に表示されます。

drop shadow appear

私は下にスクロールした後、ドロップシャドウが消える:

drop shadow disappear

私は別のタブ、ドロップシャドウをクリックした後、同様に消える:

drop shadow disappear after i clicked another tab

しかし、もう一度スクロールして最初のデスティネーションまでクリックすると、再びシャドウが表示されます。

drop shadow appears again!

私はすでにSO超える精練が、私は答えを見つけるように見えることができます。あなたたちが私を助けてくれることを願っています。

マイコード:私はすでに試してみました

<?xml version="1.0" encoding="utf-8"?> 
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" 
    xmlns:app="http://schemas.android.com/apk/res-auto" 
    xmlns:tools="http://schemas.android.com/tools" 
    android:id="@+id/content_view" 
    android:layout_width="match_parent" 
    android:layout_height="match_parent"> 

    <android.support.v7.widget.Toolbar 
     android:id="@+id/toolbar_lane" 
     android:layout_width="match_parent" 
     android:layout_height="?attr/actionBarSize" 
     android:background="@color/lighter_purple_99" 
     android:elevation="4dp" 
     android:gravity="center_vertical" 
     android:paddingLeft="16dp" 
     android:paddingTop="4dp"> 

     <ImageView 
      android:id="@+id/img_lane_settings" 
      android:layout_width="20dp" 
      android:layout_height="20dp" 
      android:layout_gravity="right" 
      android:layout_marginRight="14dp" 
      android:src="@drawable/icn_settings" /> 

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


    <android.support.design.widget.TabLayout 
     android:id="@+id/tabs2" 
     android:layout_width="match_parent" 
     android:layout_height="wrap_content" 
     android:layout_marginTop="?attr/actionBarSize" 
     app:tabIndicatorColor="@color/white_100" 
     android:background="@color/lighter_purple_99" 
     app:layout_behavior="@string/appbar_scrolling_view_behavior" 
     android:elevation="4dp"/> 

    <View 
     android:id="@+id/shadow_below_tabs2" 
     android:layout_width="match_parent" 
     android:layout_height="8dp" 
     android:layout_below="@+id/tabs2" 
     android:background="@drawable/shadow"/> 

    <android.support.v4.view.ViewPager 
     android:id="@+id/pager" 
     android:layout_width="match_parent" 
     android:layout_height="match_parent" 
     android:layout_below="@id/tabs2" 
     android:keepScreenOn="true" 
     tools:context="TabActivity" /> 

</RelativeLayout> 

描画可能/ shadow.xml

<?xml version="1.0" encoding="utf-8"?> 
<shape xmlns:android="http://schemas.android.com/apk/res/android"> 
    <gradient 
     android:startColor="@android:color/transparent" 
     android:endColor="#ff000000" 
     android:angle="90"> 
    </gradient> 
</shape> 

を - AppBarLayoutしかし、それは見えますので、ドロップシャドウの背景があります醜い。

あなたが私を助けてくれることを願っています。前もって感謝します!

答えて

0

解決済み!

シャドウビューをビューページの下に置くだけです。このようにして、影は最後に表示され、ビューページの上部に配置されます。

<?xml version="1.0" encoding="utf-8"?> 
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" 
    xmlns:app="http://schemas.android.com/apk/res-auto" 
    xmlns:tools="http://schemas.android.com/tools" 
    android:id="@+id/content_view" 
    android:layout_width="match_parent" 
    android:layout_height="match_parent"> 

    <android.support.v7.widget.Toolbar 
     android:id="@+id/toolbar_lane" 
     android:layout_width="match_parent" 
     android:layout_height="?attr/actionBarSize" 
     android:background="@color/lighter_purple_99" 
     android:elevation="4dp" 
     android:gravity="center_vertical" 
     android:paddingLeft="16dp" 
     android:paddingTop="4dp"> 

     <ImageView 
      android:id="@+id/img_lane_settings" 
      android:layout_width="20dp" 
      android:layout_height="20dp" 
      android:layout_gravity="right" 
      android:layout_marginRight="14dp" 
      android:src="@drawable/icn_settings" /> 
    </android.support.v7.widget.Toolbar> 

    <android.support.design.widget.TabLayout 
     android:id="@+id/tabs2" 
     android:layout_width="match_parent" 
     android:layout_height="wrap_content" 
     android:layout_marginTop="?attr/actionBarSize" 
     app:tabIndicatorColor="@color/white_100" 
     android:background="@color/lighter_purple_99" 
     app:layout_behavior="@string/appbar_scrolling_view_behavior" 
     android:elevation="4dp"/> 

    <android.support.v4.view.ViewPager 
     android:id="@+id/pager" 
     android:layout_width="match_parent" 
     android:layout_height="match_parent" 
     android:layout_below="@id/tabs2" 
     android:keepScreenOn="true" 
     tools:context="com.dojomadness.lolsumo.activities.LaneActivity" /> 

    <View 
     android:id="@+id/shadow_view" 
     android:layout_width="match_parent" 
     android:layout_height="4dp" 
     android:layout_below="@id/tabs2" 
     android:background="@drawable/shadow" 
     /> 
</RelativeLayout> 
関連する問題