shape

Android - how to define ShapeDrawables programmatically?

筅森魡賤 提交于 2019-11-26 15:53:54
问题 What I'm trying to achieve is to use a Drawable with a couple of layers inside it, but control some values at runtime such as the startColor for the gradient. Here's what I have in my_layered_shape.xml: <?xml version="1.0" encoding="utf-8"?> <layer-list xmlns:android="http://schemas.android.com/apk/res/android" > <item> <shape android:shape="rectangle"> <stroke android:width="1dp" android:color="#FF000000" /> <solid android:color="#FFFFFFFF" /> </shape> </item> <item android:top="1dp" android

SVG to Android Shape [closed]

我怕爱的太早我们不能终老 提交于 2019-11-26 15:14:36
问题 As it currently stands, this question is not a good fit for our Q&A format. We expect answers to be supported by facts, references, or expertise, but this question will likely solicit debate, arguments, polling, or extended discussion. If you feel that this question can be improved and possibly reopened, visit the help center for guidance. Closed 7 years ago . I'm wondering how vector drawing in Android with the Shape class may resemble another vector drawing standard. Since Shape is a

Changing color in a shape inside a layer-list programmatically

。_饼干妹妹 提交于 2019-11-26 14:44:52
问题 I am trying to change programmatically the color of the selectable_kachel_shape . Here is the xml file: kachel_ticked_style.xml <layer-list xmlns:android="http://schemas.android.com/apk/res/android" > <item> <shape android:id="@+id/selectable_kachel_shape" android:shape="rectangle" > <stroke android:width="5dp" android:color="@color/headrbar_color" /> </shape> </item> <item> <rotate android:fromDegrees="45" android:pivotX="120%" android:pivotY="100%" android:toDegrees="45" > <shape android

Image/Graphic into a Shape

孤人 提交于 2019-11-26 14:41:32
I was wondering whether there is any way to convert an image/graphic into a Shape ? For example, can I convert the outline of a motorcycle shape into a Shape so I can then use it in Java? I know you can do it with normal squares or with rounded corners, polygons, etc. But is there a way to do a custom shape? motorcycle.jpg motorcycle-03.png ImageOutline.java This code requires some patience (when running). import java.awt.*; import java.awt.image.BufferedImage; import java.awt.geom.Area; import javax.imageio.ImageIO; import java.io.File; import java.util.Date; import javax.swing.*; /*

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

≡放荡痞女 提交于 2019-11-26 14:15:40
I want to create a rectangular shape that will be resized with the touches of the user. Below image is a good example of what i want to do: Is there any example like that? What do I need to study to implement this? Thanks in advance, To implement a custom view, you derive a class from View :) Override onDraw() for looks, override onTouchEvent() for input processing. Note that in Android, you cannot draw on view outside onDraw() ; if you want to refresh the view, call invalidate() . You can implement draggable corners as separate views. For looks, just use ready-made images (feel free to derive

Creating an Isoceles Trapezoid shape

ε祈祈猫儿з 提交于 2019-11-26 11:40:01
问题 I\'m wondering if I could produce something similar to this with CSS: And I\'m also wondering, is this the right place for such a question? I have not tried anything codewise, I\'ve done the brown images with photoshop. Thanks for any help ! 回答1: 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

Change shape solid color at runtime inside Drawable xml used as background

孤街浪徒 提交于 2019-11-26 11:01:40
问题 I\'ve a Drawable xml file (background.xml): <?xml version=\"1.0\" encoding=\"UTF-8\"?> <layer-list xmlns:android=\"http://schemas.android.com/apk/res/android\" > <item> <shape> ........... </shape> </item> <item android:id=\"@+id/shape_id\"> <shape android:shape=\"rectangle\"> <solid android:color=\"#ffefefef\" /> </shape> </item> </layer-list> used by a LinearLayout: <?xml version=\"1.0\" encoding=\"utf-8\"?> <LinearLayout xmlns:android=\"http://schemas.android.com/apk/res/android\" android

How can I smooth my JFrame shape

折月煮酒 提交于 2019-11-26 09:57:40
问题 I gave my JFrame window a custom shape with rounded corners but how can I smooth it(anti-aliasing) 回答1: 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 any of it's existing // settings. This makes it easier to manage the graphics context as we //

How do I draw an arrowhead (in Android)?

假如想象 提交于 2019-11-26 09:45:15
问题 I\'m fairly new to Android and have been toying around with Canvas. I\'m attempting to draw an arrow but I\'m only having luck with drawing the shaft, none of the arrowhead is working. I have searched a bit and found a Java example, but Android doesn\'t have GeneralPath or AffineTransform . Right now my code looks like the following (the arrowhead looks nothing like an arrowhead): public class DrawableView extends View { Context mContext; private int centerX; private int centerY; private int

Android: Using linear gradient as background looks banded

喜夏-厌秋 提交于 2019-11-26 06:14:43
问题 I\'m trying to apply a linear gradient to my ListView. This is the content of my drawable xml: <?xml version=\"1.0\" encoding=\"utf-8\"?> <shape xmlns:android=\"http://schemas.android.com/apk/res/android\"> <gradient android:startColor=\"#3A3C39\" android:endColor=\"#181818\" android:angle=\"270\" /> <corners android:radius=\"0dp\" /> </shape> So I apply it to my ListView with: android:background=\"@drawable/shape_background_grey\" It works but it looks very \"banded\" on emulator and on a