How to make android app's background image repeat

来源:互联网 发布:vscode在插件 编辑:程序博客网 时间:2024/06/05 18:09

Here is a pure-java implementation of background image repeating:

@Overridepublic void onCreate(Bundle savedInstanceState) {    super.onCreate(savedInstanceState);    Bitmap bmp = BitmapFactory.decodeResource(getResources(), R.drawable.bg_image);    BitmapDrawable bitmapDrawable = new BitmapDrawable(bmp);    bitmapDrawable.setTileModeXY(Shader.TileMode.REPEAT, Shader.TileMode.REPEAT);    LinearLayout layout = new LinearLayout(this);    layout.setBackgroundDrawable(bitmapDrawable);}

In this case, our background image would have to be stored in res/drawable/bg_image.png.

原创粉丝点击