How does Ext JS set the minimum width of a textfield body? - width

Say that a textfield is flexed horizontally and no minWidth value has been set. If you resize the textfield to have a small enough width, the body will have its own default minimum width. The following is an example: https://fiddle.sencha.com/#view/editor&fiddle/2hp9
How does Ext JS set the minimum width of the textfield body?

Never mind. I debugged, and I tried textfield.el.dom to show all the elements that composed the textfield. I found out that the element with a data-ref value of 'inputEl' had padding-left and padding-right values. I think that is what makes up the default amount of space of the body.

Related

How to find bit length of text with specific font and font size

I'm developing NativeScript JavaScript code to create dynamic text marker for maps. I have the code working that creates a marker for a specific string. My next step is to take any given string, determine its height and width in bits, and create the marker sized to contain the text.
My problem is finding the size of the text, given the text string itself, the font size, and the font family.
It looks like getMeasuredWidth could work, except that the string must already be loaded on a page before that function will return a value. In my case, I simply need to compute the size; the text won't otherwise appear as such on a page (the text in the marker becomes an image).
Is there a way to do this?
var bmp = BitmapFactory.create(200);
bmp.dispose(function (b) {
try {
b.drawRect(
"100,34", // size
'0,0', // upper-left coordinate
KnownColors.Black, // border color
KnownColors.Cornsilk // fill color
);
b.writeText(
"Parking",
"2,25",
{ color: KnownColors.Black, size: 8, name: 'fontawesome-webfont', });
...
In the code above, the width of "100" of the bounding rectangle actually represents the bit width of "Parking" with a small amount of padding. What I want to does calculate the rectangle's height and width and not hard-code it.
Try this, finding label size without adding it to Page upon button click
export function onFindButtonTap(args: EventData) {
const button = <any>args.object;
const label = new Label();
label.text = "Hello, found my size?"
label.fontSize = 20;
(<any>label)._setupAsRootView(button._context);
label.onLoaded();
label.measure(0, 0);
console.log(`Width : ${label.getMeasuredWidth()} x Height : ${label.getMeasuredHeight()}`);
}
Playground Sample
Note: I didn't get a chance to test it with iOS yet, let me know if you hit any issues.

How to get the value of the element size when element inspecting in browser?

How to get the value of the element size when element inspecting in browser ? I mean, how to get 402x48 via selenium or something ?
Picture
you can use selenium for this
getAttribute(arg0) method.
String width = driver.findElement(image locator).getAttribute("width");
String height = driver.findElement(image locator).getAttribute("height");
print(driver.find_element_by_xpath("//someXpath").size) # gives size of the element as width & height.

filling available space inside a vertical layout

in my vaadin project i have a vertical layout (with the height 100%), with two other vertical layouts inside. the fist one has a fixed height, while the second one should fill the remaining space of the browser-window. it will have a bigger height than the remaining space and has an overflow-y: scroll css-attribute. i tried this with the method setExpandRatio but did not work (the height was often more than the remaining space). can i achieve this just with vaadin, or do i have to use javascript for this?
AbstractOrderedLayout root = new VerticalLayout();
root.setHeight(100, Unit.PERCENTAGE);
AbstractOrderedLayout child1 = new VerticalLayout();
AbstractOrderedLayout child2 = new VerticalLayout();
child1.setHeight(200, Unit.PIXELS);
root.addComponent(child1);
child2.setHeightUndefined();
root.addComponent(child2); // child2 will be filled with items. if its higher than the remaining space, it should be scrollable (overflow-y: auto)
// root.setExpandRatio(child2, 1F);
So if i've understood right you would like to have a first area with fixed height and a second area that could be bigger than remaining height so it needs to scroll.
If that's the case, here's the layout
VerticalLayout"Main" (sizeFull)
VerticalLayout"1" (width 100%, height fixed): fill this layout with your fixed height content
Panel (sizeFull + setExpandRation on VerticalLayoutMain to 1)
VerticalLayout"2" (width100%, heightUndefined): fill this layout with your other content
Regards

How to get the exact actual parents width or height with an absolute positioning for childs?

Am creating elements and there childs dynamically, with different absolute positions, the childs have a left, top, width and height properties, the problem is whatever I tried, the parents width and height is always 0. Check this fiddle.
var my_parent = document.getElementById('my_obj');
var chld1 = document.createElement('div');
my_parent.appendChild(chld1);
$(chld1).css({
position:'absolute',
left:10,
top:50,
width:60,
height:20,
background:'pink'
});
alert($(my_parent).width());
Is there a simple way to get the width & height of the parent? (javascript & jQuery since evrything is happening dynamically)
Or I have to create a function that goes over all the childs & childs of childs, check the minimum left, top, then included the width & height of childs... that might take me days? or there's magical JavaScript or jQuery plugin that gives you that?
The problem is with your child' absolute position. whenever child uses absolute position, it will not fill the parent. So either don't use absolute positioning or either give the parents a fixed width

How can I get the screen width and length in android?

I want to display 9 buttons in the middle of the display, three on each row. In conclusion a big square that is composed from 9 little buttons displayed in the middle of the screen.
So I think I need to know the screen size to display buttons.
you only need to use Tablelayout or Linerlayout for this.but if need to know screen size it get as following :
Display display = getWindowManager().getDefaultDisplay();
int width = display.getWidth();
int height = display.getHeight();
If you're not in an Activity you can get the default Display via WINDOW_SERVICE:
WindowManager wm = (WindowManager) ctx.getSystemService(Context.WINDOW_SERVICE);
Display display = wm.getDefaultDisplay();

Resources