问题
I have a ListView
in an XML-layout. I want to set a new background to this view by using the following code:
BitmapDrawable TileMe = new BitmapDrawable(BitmapFactory.decodeResource(getResources(), R.drawable.bg_skyline));
TileMe.setGravity(Gravity.BOTTOM); // Bottom
TileMe.setTileModeX(Shader.TileMode.REPEAT);
ListView test = getListView();
test.setBackgroundDrawable(TileMe);
The problem is that if I leave both the Gravity
and the TileMode
lines uncommented, only TileMode
will work. If i comment the TileMode
line, the Gravity
line will work.
Am I doing something wrong or is Android messing with my head?
回答1:
Gravity is ignored when the tile mode is enabled. Link
来源:https://stackoverflow.com/questions/8401143/android-setting-both-tilemode-and-gravity