推荐安卓开发神器(里面有各种UI特效和android代码库实例)

先上图:


让背景小图不是拉伸而是多个重复
 

<xml version="1.0" encoding="utf-8"?>
<LinearLayout
android:id="@+id/MainLayout"
xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:orientation="vertical"
android:background="@drawable/backrepeat"
>
 


backrepeat.xml

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

 
代码方式:

Java代码 让背景小图不是拉伸而是多个重复 让背景小图不是拉伸而是多个重复让背景小图不是拉伸而是多个重复
  1. Bitmap bitmap = BitmapFactory.decodeResource(getResources(), R.drawable.icon);   
  2. BitmapDrawable bd = new BitmapDrawable(bitmap);   
  3. bd.setTileModeXY(TileMode.REPEAT , TileMode.REPEAT );   
  4. bd.setDither(true);   
  5. view.setBackgroundDrawable(bd);  

相关文章:

  • 2021-11-27
  • 2021-11-30
  • 2022-12-23
  • 2021-11-24
  • 2022-01-30
  • 2022-02-07
  • 2021-05-01
猜你喜欢
  • 2022-03-01
  • 2021-10-30
  • 2021-09-29
  • 2022-01-08
相关资源
相似解决方案