android background repeat-y

守給你的承諾、 提交于 2019-12-08 03:24:06

问题


I have an image that I want to position in the right and repeat it on y axis. Something like "background: url(img.png) right repeat-y" in HTML.

Is it possible to do this in android?

When I set this bitmap as a background it's not in the right:

<bitmap xmlns:android="http://schemas.android.com/apk/res/android"
  android:src="@drawable/img_list"
  android:filter="true"
  android:dither="true"
  android:tileMode="repeat"
  android:gravity="right" />

回答1:


I use the following code for repeating a image on y axis as background:

 <bitmap xmlns:android="http://schemas.android.com/apk/res/android"
        android:src="@drawable/background"
        android:tileMode="repeat"
        android:antialias="true"
        android:dither="false"
        android:filter="false"
        android:gravity="left"
    />

For seperate TileModes for X and Y u need to do this in code:

    BitmapDrawable TileMe = new BitmapDrawable(BitmapFactory.decodeResource(getResources(), R.drawable.listbackground));
      //TileMe.setTileModeX(TileMode.REPEAT);
      TileMe.setTileModeY(TileMode.REPEAT);


来源:https://stackoverflow.com/questions/11036447/android-background-repeat-y

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!