Azulejo de mapa de bits de Android sólo en X

Quiero utilizar un mapa de bits que Tile en el Horizontal sólo, hay alguna manera de hacerlo, por lo que se expande sólo en X como repetir x en CSS. I que usa el código siguiente pero la teja del bitmap Horizontal y vertical:

<?xml version="1.0" encoding="utf-8"?> <bitmap xmlns:android="http://schemas.android.com/apk/res/android" android:src="@drawable/pinstripe" android:tileMode="repeat" android:gravity ="top|fill_horizontal" android:dither="true"/> 

Aquí está la solución. Puede crear BitmapDrawable en código y especificar sólo el modo de mosaico X Android Tile Bitmap

Yo quería repetir el fondo sólo verticalmente, así, pero no pude encontrar ninguna solución decente por ahí, por lo que escribí este mi propio, espero que esto puede ayudar a alguien por ahí *

 /** * Created by LeoLink on 2014-06-24. */ public class VerticallyRepeatedBackgroundLinearLayout extends LinearLayout { private int width, height; private RectF mRect; public VerticallyRepeatedBackgroundLinearLayout(Context context) { super(context); init(context); } public VerticallyRepeatedBackgroundLinearLayout(Context context, AttributeSet attrs) { super(context, attrs); init(context); } public VerticallyRepeatedBackgroundLinearLayout(Context context, AttributeSet attrs, int defStyleAttr) { super(context, attrs, defStyleAttr); init(context); } private void init(Context context) { setWillNotDraw(false); mRect = new RectF(); } @Override protected void onSizeChanged(int w, int h, int oldw, int oldh) { super.onSizeChanged(w, h, oldw, oldh); if (oldw == 0 && oldh == 0 && w > 0 && h > 0) { width = w; height = h; } } @Override protected void onDraw(Canvas canvas) { super.onDraw(canvas); // clear the canvas canvas.drawColor(Color.WHITE); // draw Drawable bg = getBackground(); Bitmap bm = ((BitmapDrawable)bg).getBitmap(); int w = bg.getIntrinsicWidth(); int h = bg.getIntrinsicHeight(); int drawWidth = width; int drawHeight = drawWidth * h / w; int bottom = 0; while (height > bottom) { mRect.set(0, bottom, drawWidth, bottom + drawHeight); canvas.drawBitmap(bm, null, mRect, null); bottom += drawHeight; } } } 

Y en su XML

 <com.blah.blah.VerticallyRepeatedBackgroundLinearLayout android:id="@+id/collection_container" android:layout_width="match_parent" android:layout_height="wrap_content" android:background="@drawable/your_tile_bg"> </com.blah.blah.VerticallyRepeatedBackgroundLinearLayout> 
  • Convertir mapa de bits en byteArray android
  • Comparación de imágenes de mapa de bits en Android
  • OutofMemoryError: el tamaño de mapa de bits supera el presupuesto de VM (Android)
  • Android: Error al usar el mapa de bits para mostrar la imagen usando el estudio de Android
  • ImageView se estrelló la aplicación
  • Android: ¿Es posible dibujar una vista en la parte superior del mapa como una superposición
  • Canvas.drawBitmap () tarda más tiempo en dibujar el mapa de bits por primera vez mientras que el mosaico del mapa de bits
  • No se puede pasar mapa de bits entre actividades en android
  • Obtener mapa de bits de zoom visible android imagen
  • Android: tamaño de mapa de bits supera 32 bits en DialogFragment
  • Mapbox GL utilizando mapas externos
  • FlipAndroid es un fan de Google para Android, Todo sobre Android Phones, Android Wear, Android Dev y Aplicaciones para Android Aplicaciones.