I create A shape for Text View Background
<shape xmlns:android="http://schemas.android.com/apk/res/android"
android:shape="rectangle">
<gradient
android:startColor="#800e1520"
android:endColor="#801e252f"
android:angle="45"/>
<padding android:left="7dp"
android:top="7dp"
android:right="7dp"
android:bottom="7dp" />
<corners android:radius="8dp" />
and my textview is :
<TextView
android:id="@+id/textView1"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:layout_below="@+id/rel1"
android:layout_centerHorizontal="true"
android:layout_marginTop="8dp"
android:background="@drawable/rounded_corners"
android:gravity="right"
android:lineSpacingExtra="6dp"
android:supportsRtl="true"
android:text="@string/hello_world"
android:textColor="#FFFFFF" />
when text is short like this
but when text is too large not showing background and eclipse logcat show
Shape round rect too large to be rendered into a texture (424x5884, max=2048x2048)
how to solve it? thank you
You could also try to make your background .9.png
Edit: The easiest solution is to get rid of the rounded corners. If you remove the rounded corners and use a simple rectangle, the hardware renderer will no longer create a single large texture for the background layer, and won't run into the texture size limit any more.
One simple workaround should be to revert to software rendering for that view:
...but we've run into a similar problem here and we got the same result you did, the view (and its children) didn't render.
You can also set the layer type of a view from XML:
Setting the layerType to "none" instead of software seems to cause the view to draw, but it drew without the rounded corners in a quick test we just tried.
Another approach might be to use a different method of rendering the rounded rectangle, e.g.
onDraw
PaintDrawable
(which supports rounded corners, but must be set from code)My Solution is to draw onto the canvas. See below.
If you need to do gradents etc then look at
Shader
's, https://developer.android.com/reference/android/graphics/LinearGradient.html Should do what you need it too.