Rounded corner for textview in android

Create rounded_corner.xml in the drawable folder and add the following content, <?xml version=”1.0″ encoding=”utf-8″?> <shape xmlns:android=”http://schemas.android.com/apk/res/android” > <stroke android:width=”1dp” android:color=”@color/common_border_color” /> <solid android:color=”#ffffff” /> <padding android:left=”1dp” android:right=”1dp” android:bottom=”1dp” android:top=”1dp” /> <corners android:radius=”5dp” /> </shape> Set this drawable in the TextView background property like so: android:background=”@drawable/rounded_corner” I hope this is useful for you.

Creating an Isoceles Trapezoid shape

This shape (an Isoceles Trapezoid) can be easily made using CSS3 by rotating a div with a bit of perspective. Explanation The shape is achieved by rotating an absolutely positioned pseudo-element (.container:after) along the x-axis with a perspective. We are not rotating the actual container div because it would cause the link (and any other) … Read more

Scaling/Translating a Shape to a given Rectangle using AffineTransform

Note that AffineTransform transformations are concatenated “in the most commonly useful way”, which may be regarded as last in, first-out order. The effect can be seen in this example. Given the sequence below, the resulting Shape is first rotated, then scaled and finally translated. at.translate(SIZE/2, SIZE/2); at.scale(60, 60); at.rotate(Math.PI/4); return at.createTransformedShape(…);

How do I scale a PyGame image (Surface) with respect to its center?

You missed to update the size of self.pixeltitlerect after the Surface has been scaled: self.pixeltitle = pg.transform.scale(self.pixeltitle,(xsize,ysize)) # size of surface has been changed get the new rectangle self.pixeltitlerect = self.pixeltitle.get_rect() self.pixeltitlerect.center = (250,120) self.screen.blit(self.pixeltitle,self.pixeltitlerect) Or even shorter (see pygame.Surface.get_rect()): self.pixeltitle = pg.transform.scale(self.pixeltitle,(xsize,ysize)) self.pixeltitlerect = self.pixeltitle.get_rect(center = (250,120)) self.screen.blit(self.pixeltitle,self.pixeltitlerect) Do not scale the original Surface. … Read more

How can I smooth my JFrame shape

A lot will come down to how you are rendering your content, but the basic concept is to supply rendering hints to the Graphics context you are drawing to… For example, if I was painting to a component, I might use something like… // Create a “copy” of the graphics context so we don’t modify … Read more

Two Rectangles intersection

if (X1+W1<X2 or X2+W2<X1 or Y1+H1<Y2 or Y2+H2<Y1): Intersection = Empty else: Intersection = Not Empty If you have four coordinates – ((X,Y),(A,B)) and ((X1,Y1),(A1,B1)) – rather than two plus width and height, it would look like this: if (A<X1 or A1<X or B<Y1 or B1<Y): Intersection = Empty else: Intersection = Not Empty

How to create a resizable rectangle with user touch events on Android?

Chintan Rathod’s answer was great solution but there are something wrong when He draws the rectangle. I just edit some lines of code to make it works correctly with user touch event. Now, you can add this view to your layout then touch to draw. import java.util.ArrayList; import android.content.Context; import android.graphics.Bitmap; import android.graphics.BitmapFactory; import android.graphics.Canvas; … Read more

tech