Android-同时设置TileMode和Gravity [英] Android - Setting both TileMode and Gravity

查看:59
本文介绍了Android-同时设置TileMode和Gravity的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在XML布局中有一个 ListView .我想使用以下代码为此视图设置新的背景:

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);

问题是,如果我不对 Gravity TileMode 行进行注释,则只有 TileMode 可以工作.如果我注释 TileMode 行,则 Gravity 行将起作用.

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.

我做错了事还是Android弄乱了我的头?

Am I doing something wrong or is Android messing with my head?

推荐答案

启用平铺模式时,重力将被忽略.链接

Gravity is ignored when the tile mode is enabled. Link

这篇关于Android-同时设置TileMode和Gravity的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆