【问题标题】:Android: Transparent gradient viewAndroid:透明渐变视图
【发布时间】:2017-02-23 18:14:07
【问题描述】:

我搜索了这个问题,发现了很多答案,人们声称这些答案有效,我不怀疑。但是,就我而言,这些答案都没有帮助。我需要工具栏下的透明渐变视图,以便在滚动RecyclerView 时,它在该渐变视图下可见。甚至可能吗? 我试过这样做:

<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>

【问题讨论】:

  • 您是否将背景设置为Toolbar
  • 我做了,但是这个可绘制对象应用于位于下方的视图。此视图始终具有白色背景。

标签: android view gradient


【解决方案1】:

您可以使用回收视图。下面给出示例代码

<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>

这会有所帮助。

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2014-07-21
    • 2012-01-12
    • 2016-10-28
    • 1970-01-01
    • 2011-02-07
    相关资源
    最近更新 更多