2017-02-23 5 views
0

私はこの質問を検索し、多くの回答が見つかっており、人々はそれらの回答が機能していると主張しています。しかし、私の場合は、これらの答えのどれも役立たない。私は、ツールバーで透明なグラデーションビューが必要なので、RecyclerViewをスクロールすると、そのグラデーションビューの下に表示されます。それも可能ですか? 私はこれをやってみました:Android:透明グラディエントビュー

<shape xmlns:android="http://schemas.android.com/apk/res/android" 
android:shape="rectangle"> 
<gradient 
    android:startColor="#e9e8e9" 
    android:endColor="#30ffffff" 
    android:angle="270" 
    > 
</gradient> 

これは、しかし、任意の透明性がありません。私も"@android:color/transparent"を試しましたが、まだ運がありません。

<RelativeLayout 
    android:id="@+id/layout_button_category"> 
    .... 
    </RelativeLayout> 
    <View android:id="@+id/shadow" 
     android:layout_below="@+id/layout_button_category" 
     android:layout_width="match_parent" 
     android:layout_height="24dp" 
     android:dither="true" 
     android:background="@drawable/shadow" 
     xmlns:android="http://schemas.android.com/apk/res/android" /> 
</android.support.design.widget.AppBarLayout> 
+0

「ツールバー」に背景を設定しました –

+0

でしたが、この図面は下にあるビューに適用されます。このビューは常に白い背景を持ちます。 – Sermilion

答えて

0

あなたはリサイクルビューを使用することができます。

これはレイアウトがある方法です。サンプルコードは次のとおりです。

<android.support.v7.widget.RecyclerView 
android:layout_width="match_parent" 
android:layout_height="wrap_content" 
android:id="@+id/recyclerView" 
android:scrollbars="vertical" 
android:scrollbarThumbVertical="@drawable/gradiant 
/> 

ステップ2グラデーションxml

<?xml version="1.0" encoding="utf-8"?> 
<shape xmlns:android="http://schemas.android.com/apk/res/android"> 
<gradient android:startColor="#000" android:endColor="#000" 
    android:angle="45"/> 
<corners android:radius="6dp" /> 
</shape> 

これは役に立ちます。

関連する問題