如何为ScrollView添加边框,将图像保留为背景?

时间:2015-04-08 05:50:02

标签: android background scrollview border

我想为ScrollView添加边框,但我也希望将图像作为背景。

到目前为止,我使用GradienDrawable()来设置ScrollView的边框,但是,我不知道如何将图像设置为背景,而不会覆盖图像

这是我的代码的一部分:

public class Statistics extends ScrollView

{

public Statistics(int displayMode,Context context,int W, int H) {
    super(context);

    GradientDrawable borde =  new GradientDrawable();

    borde.setColors(new int[]{0x1F22FF22,0xAA22FF22,0x1F22FF22});
    borde.setGradientType(borde.LINEAR_GRADIENT);
    borde.setColor(0x1F22FF22);
    borde.setCornerRadius(10);
    borde.setStroke(5, 0xF000BE96);

    setBackground(borde);
    setBackgroundResource(R.drawable.fondo2);
    setPadding(5,5,5,5);

    if(displayMode == LinearLayout.VERTICAL)
    {
        setLayoutParams(new ViewGroup.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, (int) (H * 0.25)));
    }
    else
    {
        setLayoutParams(new ViewGroup.LayoutParams((int)(W*0.25),H));
    }

}

}

有人可以帮助我吗? 或者可以建议另一种方法来做到这一点?

事先,非常感谢你。

0 个答案:

没有答案