draw9patch showing the border in the emulator - java

Can anyone tell me why the black borders are appearing in the emulator, and how to remove them?

Add black lines along the upper edge and the left edge, it could be that the device does not accept it as a valid nine-patch if you are missing black on any of the sides.
This could be related to ninepatches that have 'gaps' in the black lines appear to work in the editor, but will not work on a device.
Edit:
And as #ByteMe states in a comment, make sure you have the .9.png at the end of the filename.

When I had this problem it was because I forgot to rename the images!! This shouldn't be an issue if you use the tools provided by Google to make draw9... but it'w worth double checking!
image should be named *.9.png

Related

Android studio XML centercrop doesn't center the image

I have added a background-image in Android Studio, I used center-crop to center it.
The problem I have is that the image does not center properly. it's slightly off to the right and I want it perfectly centered
Look on the right the stars are not well centered.
Here's what I have tried
Could you help me ?
Thank you.
Thanks for updating your question with the background image (bouclier.jpg) that you're using. The issue you're experiencing is not to do with your layout (XML) code, but rather with the image itself.
As you can see, your background image appears to be offset to the right ever so slightly (I've added a green cross in the above image to illustrate this). As a result, when you use android:scaleType="centerCrop" the image is correctly centred but doesn't look right.
My recommendation would be to choose a different (properly centred) image to use as your background, or alternatively to centre the image you're presently using.
I hope that helps!

Rotate text and icons of an android app

My question is how can I modify this code (the selected method):
https://github.com/dudeofawesome/CardboardHome/blob/master/app/src/main/java/dudeofawesome/cardboardhome/Launcher.java#L721
so the text (name of the app like in the photo and icons) are rotated
Thanks a lot!
Try the method Canvas.drawTextOnPath, with a path that goes along the line you want but from right to left, instead of left to right, which would draw the text as you have it already. The picture doesn't show any rotation, so it's unclear what you want your end result to look like.
Or try this.
Disclaimer: I only used it once to make curved text by specifying two paths, separate for the top and bottom. It may also be more of what you want:

OpenCV Detect Bottom of Die

So this is what I have: a camera filming a set of dice. The blue rects indicate regions of interest and in each ROI I would want to see if there's a die placed there and which side of the die is showing (these dice are just placeholders, I'm not working on anything related to Dungeon Roll!).
I think the problem is rather plain to see: since I'm using a very wide angle camera, not only do I see the side of the die with the scroll (which would be the side the camera is pointing to), but also ie the swords in the top right and bottom left.
I'm having a hard time thinking of how to get this to work. How can I go about figuring out which side is the "correct" side that I'm trying to identify?
Thank you!
So, the solution is more hardware than software based, but it works like a charm!
I put a clear plastic folder with a bumpy surface on top of the glass panel and then put the dice on that. the result: only things close to the refractive surface are displayed clearly enough and everything farther away kind of disappears. Play with amount of folders and settings of edge detection and the result will be satisfactory!
Though I'm sure Micka and stacker's comments would've led me to find the solution this quick fix is good enough for my current testing. thank you!

Android - 9 patch

I'm trying to create a new spinner background using a 9 patch picture. I've tried many ways to get a perfect image but I failed :s
Here is my 9 patch:
The content looks to be good when I simulate with Draw-9-patch but the part with the arrow is not displayed, or when it is, this part is totally mal-formed.
I've put the top black line to the whole size and the problem is still the same.
Do you know how to solve it?
Thanks.
Regards.
V.
First of all, you've marked your rounded corners as stretchable, this should be avoided so your corners stay the same, no matter how its stretched.
You've also marked your arrow as being stretchable vertically, which I suppose is not desirable.
See the attached image for a fixed 9-patch (note the differences in 9-patch frame compared to your image), this should scale well in all directions.

How to remove black border around transparent image in PDF created by iText

I have searched over bunch of sites, and I was unable to find solution for my problem.
This is the problem:
I am making PDF's in Java using iText library.
Everything works fine except one thing.
Transparent PNG images have black/gray border around non-transparent area.
I didn't set any borders in code, and actually I have tried to remove them (with no luck).
Can someone help me how to solve this problem?
The closest answer what I have found is: Resizing an image in asp.net without losing the image quality
But I cannot (don't know) interpret this code in Java.
My code is pretty big to copy/paste, but these are steps:
create document
load image from given path
manipulate image (resize, rotate, positioning)
add image to current page
save pdf file
This is what I have tried also:
http://itext-general.2136553.n4.nabble.com/template/NamlServlet.jtp?macro=print_post&node=2157267
http://itext-general.2136553.n4.nabble.com/template/NamlServlet.jtp?macro=print_post&node=2330200
I have tried more than those 2, but I didn't bookmarked them (none of them worked)
Thanks in advance
UPDATE: I forgot to mention that my original pictures don't have border. Border is created somehow by iText. I initially thought that it was bug, but since iText 5.0.2 this problem remained so now I doubt that is bug (I am currently using 5.1.3).
UPDATE 2 I forgot to add this link: http://itext-general.2136553.n4.nabble.com/template/NamlServlet.jtp?macro=print_post&node=2157261
Here is presented VB script that works, but I cannot convert to Java code (it still draws black border), so can someone help me at least with this to convert good?
You could use the java BufferedImage method, getSubImage(x, y, w, h) which allows you to crop a sub image out of an existing image. That way you could cut out the edges.
See here: Class BufferedImage

Categories

Resources