Question

J'ai un Scrollview Android avec un fond blanc. Le bord de la décoloration est un gradient translucide blanc. Je voudrais le changer noir au lieu de blanc. J'ai un ListView dans le même projet avec un fond blanc qui a un bord de décoloration noir par défaut, mais je ne trouve pas où (si n'importe où) a été défini.

Était-ce utile?

La solution

Je viens de le découvrir par essais et erreurs.

Simplement réglé android:background="@color/yourColor" pour le <ScrollView>. Il définira l'ombre sur la couleur donnée.

Autres conseils

Si vous voulez un bord de décoloration de couleur différent de l'arrière-plan, vous devez remplacer la méthode getolidcolor () de ScrollView. Par exemple:

@Override
public int getSolidColor() {
    return Color.rgb(0x30, 0x30, 0x30);
}

You can use:

    final int glowDrawableId = context.getResources().getIdentifier("overscroll_glow",
            "drawable", "android");
    final Drawable androidGlow = context.getResources().getDrawable(glowDrawableId);
    androidGlow.setColorFilter(Color.RED, PorterDuff.Mode.SRC_IN);

    int edgeDrawableId = context.getResources().getIdentifier("overscroll_edge", "drawable",
            "android");
    final Drawable androidEdge = context.getResources().getDrawable(edgeDrawableId);
    androidEdge.setColorFilter(Color.RED, PorterDuff.Mode.SRC_IN);

You can use this:

https://github.com/AndroidAlliance/EdgeEffectOverride

enter image description here

Simple clean and working perfect!

EDIT: this does not answer the question, which was asking for ScrollView. This answer only works on AbsListView and descendants (including ListView).


Fading edge color is controlled by the android:cacheColorHint attribute.

E.g.:

<ScrollView android:cacheColorHint="#ff000000" android:background="#ffffffff" />

will set the background to white, and the cacheColorHint is used to draw the fading edge color -- in this case, it would be black.

If you don't know what changed the color of your fading edge, it was probably the application of a style or theme. Check your manifest for android:theme="something" in an Activity. If the theme is from the group android.R.style.Theme.Light the edge will be white. The default android.R.style.Theme and android.R.style.Theme.Black will have black fading edges. Themes also affect other attributes, so check out the attributes fully before you throw them in for one thing.

Do this:

  <ScrollView
    android:theme="@style/scrollUpdate"
    android:layout_width="match_parent"
    android:layout_height="0dp"
    android:layout_weight="1" >

in values\styles put the style

<style name="scrollUpdate">
    <item name="colorAccent">@color/yourcolor</item>
    <item name="android:color">@color/yourcolor</item>
    <item name="colorPrimary">@color/yourcolor</item>
    <item name="colorPrimaryDark">@color/yourcolor</item>
</style>

works to me tks!

Licencié sous: CC-BY-SA avec attribution
Non affilié à StackOverflow
scroll top