I want to implement sometthing like above where the camera tab has the smaller width compare to the others tab in TabView.
I did three tabs with same size but I don't know how to add one more tab but with smaller width.
You will have to update the width of native view that contains the camera within the tab layout. The code below lets the layout take only the width it requires to show the content within.
const view = nativeTabView.getChildAt(i),
layoutParams = view.getLayoutParams();
layoutParams.weight = 0;
layoutParams.width = android.widget.LinearLayout.LayoutParams.WRAP_CONTENT;
view.setLayoutParams(layoutParams);
Playground Sample
The above example is written in NativeScript Core / TypeScript, there is nothing you have to specifically if you are implementing this on Vue / Angular, just use the appropriate event binding syntax, you should be good.
Related
The problem to be solved here is how to zoom in a UIScrollView while staying centered. If you don't take some sort of precautions, the default is that as we zoom out, the zoomed view slides up to the top left corner of the scroll view, like this:
So how to prevent this, and keep the zoomed view in the center as we zoom? As you probably know, there are traditional ways of handling this by messing with the scroll view's layout, as described by Josh and Eliza in the brilliant classic WWDC video 104 from 2010. This can be done by using a delegate or by subclassing UIScrollView, and gives the desired result:
Now comes WWDC 2017 video 201 (https://developer.apple.com/videos/play/wwdc2017/201/?time=1496), and there's Eliza making a claim that the new (iOS 11) contentLayoutGuide solves the problem of zooming while staying centered in a new way: she says to center the content view at the center of the content layout guide.
But she doesn't demonstrate. And when I try it for myself, I find it isn't solving the problem. I'm zooming in just fine, but when zooming out, so that the zoom scale is smaller than 1, the content view moves up to the top left, just as it always has.
Has anyone figured out what this claim in the video actually means? How does iOS 11 make it easier to zoom centered than in the past?
EDIT I actually received a sample project from Apple in response to my bug report, which they claimed illustrated how to solve this, and it didn't! So I conclude that even Apple doesn't know what they're talking about here.
The view goes to the top left because the contentSize of the scroll view is not defined. When using the new Auto Layout guides in iOS 11, it's still necessary to define the contentSize.
Add the following constraints:
scrollView.contentLayoutGuide.widthAnchor.constraint(equalTo: scrollView.frameLayoutGuide.widthAnchor),
scrollView.contentLayoutGuide.heightAnchor.constraint(equalTo: scrollView.frameLayoutGuide.heightAnchor)
This worked for me, when I had a contentView with a fixed width/height and the following additional constraints:
// give the centerView explicit height and width constraints
centerView.widthAnchor.constraint(equalToConstant: 500),
centerView.heightAnchor.constraint(equalToConstant: 500),
// pin the center of the centerView to the center of the scrollView's contentLayoutGuide
centerView.centerXAnchor.constraint(equalTo: scrollView.contentLayoutGuide.centerXAnchor),
centerView.centerYAnchor.constraint(equalTo: scrollView.contentLayoutGuide.centerYAnchor)
This is the solution you are / everybody is looking for. In my case I want to center a view inside a table view scroll view. So if the table view scrolls the custom view will always be in the center of the scroll view content.
// create a view
let v:UIView = UIView(frame:CGRect.zero) // use zero if using constraints
ibTableView.addSubview(v)
ibTableView.bringSubview(toFront:v)
v.translatesAutoresizingMaskIntoConstraints = no
v.backgroundColor = .yellow
v.widthAnchor.constraint(equalToConstant:100).isActive = yes
v.heightAnchor.constraint(equalToConstant:100).isActive = yes
// set scrollview guides
ibTableView.contentLayoutGuide.widthAnchor.constraint(equalTo:ibTableView.frameLayoutGuide.widthAnchor).isActive = yes
ibTableView.contentLayoutGuide.heightAnchor.constraint(equalTo:ibTableView.frameLayoutGuide.heightAnchor).isActive = yes
// anchor view
v.centerXAnchor.constraint(equalTo:ibTableView.contentLayoutGuide.centerXAnchor).isActive = yes
v.centerYAnchor.constraint(equalTo:ibTableView.contentLayoutGuide.centerYAnchor).isActive = yes
Here goes my first question. I've embedded a youtube video (HTML5) in a panel created using the Panel API from Firefox SDK. The problem is that the video won't go fullscreen. It tries to, but goes back to normal size within the panel. I've also tried to use the method described here with a random div but the same thing happens. So, is this a limitation from the api or is there any way I could get it to work? Thanks.
I've just started experimenting with a floating YouTube player plugin using the Firefox sdk and ran in to the same issue. I did find a some what sloppy work around, that you might find suitable to use.
This method causes the panel to resize to the full screen. However, when resizing it, even with the border property set to 0, the panel will still show a bit of a border.
in the main document, "index.js"
var self = require('sdk/self');
var data = require("sdk/self").data;
let { getActiveView }=require("sdk/view/core");
let myPanel = require("sdk/panel").Panel({
contentURL: "./index.htm",
contentScriptFile: ["./youtube.js", "./index.js"]
});
var player = getActiveView(myPanel);
player.setAttribute("noautohide", true);
player.setAttribute("border", 0);
player.setAttribute('style', 'background-color:rgba(0,0,0,0);');
myPanel.show();
init();
myPanel.port.on('fullscreen', fullScreen);
function init(){
var size = 30,
width = size * 16,
height = size * 9;
myPanel.resize(width,height);
}
function fullScreen(width, height){
player.moveTo(3840, 0); // Need to moove the video to the top left
//of the monitor or else the resize only takes a potion of the screen.
//My left position is 3840 because i'm doing this on my right
//screen and the left is 4k so i need the offset.
myPanel.resize(width,height);
}
And in my content script file
var container = document.getElementById('container'),
overlay = document.getElementById('overlay');
overlay.addEventListener('click', fullscreen);
function fullscreen() {
var x = window.screen.availWidth,
y = window.screen.availHeight;
self.port.emit('fullscreen', x, y);
}
Some things I've noticed while experimenting is that when playing YouTube videos in the panel, the video has a tendency to lag, but the audio plays fine. The lag gets more apparent when moving the mouse over elements on other pages, and over the panel itself. The faster the movement the more apparent it becomes. I've found a workaround for mousing over the panel by placing an div that stretches over the video. The problem with this is that the default YouTube controls don't react to the mouse over, which would be possible to get around by using the YouTube api and creating custom controls. Also multiple monitor support would be hard to work with when positioning the video.
Edit:
Here's another way that does the same thing, but this one appears to deal with multi monitor support. It will position to the top left of whatever window firefox is currently on.
in the index.js file
function fullScreen(width, height){
myPanel.hide();
myPanel.show({position:{left:0,top:0}});
myPanel.resize(width,height);
}
I want to let the ACE editor to be resizable based on the browser's
size. however, the editor element must be explicitly sized in order to
be initialized by the ace editor's API.
The editor works when I set the width:100%/height:400px. Having this setting allows the editor 's width responsive to the browser's width. However, not responsive for the editor's height.
Is there a way to make the editor's size more flexible by responding to browser's size?
Thanks
function resizeAce() {
return $('#editor').height($(window).height());
};
//listen for changes
$(window).resize(resizeAce);
//set initially
resizeAce();
set position:absolute;top:0; bottom:0
like https://github.com/ajaxorg/ace-builds/blob/master/editor.html#L14
Expanding on jpillora's excellent guidance:
function resizeAce() {
var h = window.innerHeight;
if (h > 360) {
$('#editor').css('height', (h - 290).toString() + 'px');
}
};
$(window).on('resize', function () {
resizeAce();
});
resizeAce();
window.innerHeight is supported by IE8+ and seems reliable for getting the usable area of the screen. I ended up with identical results on IE9, FF, and Chrome. I also found that I had to use the jQuery on syntax to reliably catch the window resize event.
I needed to use jQuery css because in my case I'm resizing a pre element (that shows coding help) that sits to the right of the code editor, and this was the only way to get the two elements to exactly the same height.
The 360 and 290 are the numbers I needed to use to account for all the menus and tabs taking up vertical space at the top of my page. Adjust accordingly.
I'm targeting android but I don't know how to layout the UI so it works for all devices. How do I do this?
I have a TextField with a Button for searching and the search results are displayed below in a TableView below. So I have a table view but the bottom is cut off.
this.searchResults = Ti.UI.createTableView({
top:'70px',
height:'450dp'
});
As you can see from the code above I clearly dont know how to do this. How do you lay things out for android?
You can set top/bottom/left/right values. If you want the table to stop at the bottom edge of the screen, you could set bottom: 0. It's the same for iOS.
If I'm working on Android stuff, and I want it to resize proportionate to the size of the screen I often use percentages. So
this.searchResults = Ti.UI.createTableView({
top:'10%',
height:'90%'
});
Alternatively, If you want pin point accurate calculations, you can ask appcelerator for the platform width and height, and resize things proportionately yourself. Like so:
var height = Ti.Platform.DisplayCaps.platformHeight; //Screen height in pixels
this.searchResults = Ti.UI.createTableView({
top:'75dp',
height: (height - (75 * Ti.Platform.DisplayCaps.logicalDensityFactor)) //height - 75dp converted to pixels
});
In my asp.net web site project I want to make rad calendar control smaller programmatically that get rendered by default to the browser(which is quite big for my requirement).I tried setting height and width of the control it doesn't work.How can I fix this?
RadCalendar calendar = new RadCalendar();
calendar.Width = x;
calendar.Height = y;
Panel1.Controls.Add(calendar);
Each of the Telerik Skins actually have a minimum height and width setting for the RadCalendar in order to ensure that the visual styles of the control are not broken. As you can imagine modifying the width and height to arbitrary settings could skew the look and feel of the control quite a bit. What you can do, however, is either modify one of the existing skins or create your own. This section in their online documentation covers how to change the appearance, and the specific article covers how to create a custom skin.