I have a Custom list view. This list view is basically a chat list. For each list item i want to have a particular background , as shown in the picture.
How to implement this background? Is it possible to draw this background using xml so that it adjusts to any size ?
Rectangle can be drawn using <shape> in xml file. But how to draw the whole thing? I don't mind the background color!
Kindly help!
If you want to use an image, you should use a 9-patch.
If you want a shape, just create one and use the background attribute of your main layout
Related
I have this IText object within a parent Group object.
When I select the Group and resize it horizontally (and vertically as well) the IText resizes as well which makes the text Strech and look awfull.
Now what I would like to do is have the IText center itself (keeping its aspect ratio) within the Group.
How can I do that. I tried modifying the Width and Left of the IText when the object is scaling, but that did not work.
try use latest fabricjs version ( 1.6.0.rc1 ) and instead of using fabric.IText use fabric.Textbox.
This new class has the properties you are looking for, the controls normally used for scaling are instead used for resizing the element and the text flows inside it.
I was not able to make the latest fabric.Textbox work exactly like I wanted.
Luckily, I found a way of making the fabric.ITextcenter horizontally when the parent fabric.Group is resized horizontally and also make the same fabric.IText Text grow in size based on the vertical resize. No ugly text stretch.
Here is the solution:
https://jsfiddle.net/t44wyday/46/
I am developing an app with a home screen, that has 6 text views, arranged in some order.
Now, I want to apply an image as a background to them.
If I apply that image to the parent layout, it's not visible as it is covered by all child layouts/textviews.So, I have to apply that background individually to all the textviews, to make it visible.
But,this is not I want.
Is there a way to apply that image as a background to the parent layout in such a way, that it is visible over all the child layouts.
Means, I want to apply that image as a background such that a single image can cover all the screen and is visible over the textviews, not applying the image to all the individual texviews.
You can also take the question as, how to make the textviews transparent?
Actually, I figured out a way..
I can define a custom layout in a separate file in drawable folder.
There, I can define a selector in which I can define a shape for defining the
gradient(for background gradient
),
solid(for applying solid color)..like elements.
In the solid element, I can define the color attribute as
<solid android:color="#android:color/transparent" />
Then, I can apply this layout as a background to all the textviews.
OR, If you want no other effect rather than just applying the background, you can do this without creating the file.
To each TextView individually, apply the background as:
android:background="#android:color/transparent"
These both ways can solve the problem easily.
How to change the height and width of textarea (or any html element) from javascript which is inside foreign object in svg.Moreover, can I drag an html elelment and drop on svg container by any mean (htm5 any hint) or atleast can I get the coordinates on svg during draging so that I can implement my own drag and drop. Thanks in advance
You appear to my eye to have at least two distinct questions. If I understand correctly, the first one is something like this: how can you write JavaScript within an SVG instance so that you can embed the SVG instance and have the JS control the embedding HTML? Do I have that right?
If so, the answer can be constructed from the parts of http://phaseit.net/examples/SVG4/c1.html and related examples. Briefly, write "window.top" to reach the HTML reference.
The same sort of reference gives access to HTML5 drag-and-drop, if that's what you're after.
Is that the level of answer you're after, or do you need an executable example?
LATER, AFTER MORE DISCUSSION: it appears that http://phaseit.net/examples/SVG5/embedding.svg is more like what you're after. Do I have that right, Arslan Ahson? What you should see when you display the SVG instance there is an SVG-coded elliptical button which, when pushed, toggles the appearance (background color and width) of a nearby embedded HTML textarea.
I am working on a SVG application and now want to let a user resize an object using draggable corners, very much like in SVG-edit (http://svg-edit.googlecode.com/svn/trunk/editor/svg-editor.html).
The functionality should work as follows: The user selects an SVG object, drags it to the main ‘canvas’ and once on the ‘canvas’, four corners on the outside of the object appear, the user can drag on each of the corner points & drag to enlarge the object. The objects will be rectangular in shape and created using paths, not using the SVG ‘rect’ function.
Would anyone have any suggestions as to how this should be implemented?
Thanks in Advance
You could take a look at some existing open source implementations. svg-edit is one which you already mentioned.
To showcase a tool that I developed, I wrote a demo which implements this functionality. This which may serve as a simpler and more restrictive example than svg-edit, as it doesn't do too much other than allow you to draw rects and circles, and rotate/translate/scale them.
I have edited jquery to make rect draggable, recently put them in a g and lost this functionality. The g doesn't contain the position data.
Might be possible to bubble down to the children elements.
As far as I know ON_WM_MEASUREITEM does not get called in Custom Draw list control. It is only used if control is Owner Drawn.
I have found a way to do that, but it is somewhat a HACK and I still can not control gaps between items they are set up somehow automatically.
The trick is that you can create CImageList with the unused images of the size you need and if you assign such image list to the list control, items get resized to the dimensions close to the size of the images. After that you can use Custom Draw to paint whatever inside those enlarged items.
CImageList m_imageList1;
m_imageList1.Create(176, 144, ILC_COLOR32 | ILC_MASK, 5, 1);
GetListCtrl().SetImageList(&m_imageList1, LVSIL_NORMAL);
So the question is how do you change items size and spacing between them in Custom Drown control?
Or a fully Owner Drawn control with LVS_OWNERDRAWFIXED is my only option here?
Update.
I have compiled the same custom drawn list control in VS2008. And the look was different. The item size was perfect, and no gaps between the items. I guess that sizing problem I had was only in MFC for VS2003, I was using initially.
Man, MFC is a constant HACK spree :-)
I guess the question is closed. Thank you (me).