2014-01-26 93 views
-1

我想要有一个平铺背景,图像在水平方向重复但不垂直在Android应用程序中。换句话说,我想要一个平铺的行。我怎样才能做到这一点?Android平铺背景一行

回答

1

在这段代码中,你objetcs取代yourXYZ

RelativeLayout rl = (RelativeLayout) yourView.findViewById(R.id.yourContainer); 
BitmapDrawable bmp = (BitmapDrawable) yourContext.getResources().getDrawable(R.drawable.yourBackground); 

bmp.setTileModeY(TileMode.REPEAT); 
if(Build.VERSION.SDK_INT < Build.VERSION_CODES.JELLY_BEAN) 
{ 
    rl.setBackgroundDrawable(bg); 
} 
else 
{ 
    rl.setBackground(bg); 
}