ABe*_*oon 24
当然.只需使用LayerListDrawable.
就像是:
<layer-list xmlns:android="http://schemas.android.com/apk/res/android" >
<item>
<shape android:shape="rectangle" >
<solid android:color="#FF00ffff" />
</shape>
</item>
<item>
<bitmap
android:src="@drawable/your_tiled_drawable"
android:tileMode="repeat" />
</item>
</layer-list>
Run Code Online (Sandbox Code Playgroud)
将其保存在您的res/drawables目录中,并将其用作您的背景.
遗憾的是,如果您的应用程序更复杂,有时tileMode将无法解决.如果你跑到那里,你将不得不在Java中重新添加tile模式.
我通常仍然将其设置为xml,然后执行以下操作:
View v = findViewById(R.id.my_view);
LayerDrawable lld = (LayerDrawable) v.getBackground();
BitmapDrawable tiled = (BitmapDrawable) lld.getDrawable(1);
tiled.setTileModeXY(TileMode.REPEAT, TileMode.REPEAT);
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
8368 次 |
| 最近记录: |