How to use setLayoutParams - android-linearlayout

I am waiting to expand and contract a linear layout.
The linear layout height will be set to 0dp pixels in the beginning and once a user selects a certain button then that layout height will be expanded to MATCH_PARENT.
Once the user selects the button again the linear layout is given a height of 0dp again.
Please any help will be awesome. Thank you.

You may try something like below to set the height to 0
// Get your linearlayout
LinearLayout layout = (LinearLayout)findViewById(R.id.mylinearlayout);
// Gets the layout params that will allow you to resize the layout
LayoutParams params = layout.getLayoutParams();
// Changes the height and width to the specified *pixels*
params.height = 0;

Related

How to resized button in godot

Why when creating a button with a script in the function _ready, these buttons cannot be resized. (And position)
var pos
var siz
var yBut = 150
var but
func _ready():
siz = get_viewport().get_visible_rect().size
pos = get_viewport().get_visible_rect().position
but = Button.new()
$sc/vb.add_child(but, true)
but.rect_position = pos/2
but.rect_size = Vector2(siz.x, 150)
ps. The buttons are placed in a ScrollContainer in which the vBoxContainer.
Container controls will auto resize and position children controls. Try using the Button's size flags to suggest it's size.
You can also compose ui with multiple levels of other Container controls such as V and HBoxContainer using size flags. This will give you finer control over the whole look of the ui. This will also make it easier to add controls later that will adaptively resize.
You can also set rect_min_size and the Container will not resize it any smaller than min size. However, that may break dynamic layout.
Hope this helps!

Disable width and height fields from image properties windows

Disable width and height fields from image properties I am using ckeditor 4
CKEDITOR.replace('<%=txtCkEditor.ClientID %>', {allowedContent:'img[!src,alt];'});
By using above method it shows only image properties with width and height hidden and rest of the controls also get visible false. Kindly suggest me a solution for disabling the width and height fields from image properties windows.
Thanks in advance.
I'm not sure I entirely understand your question. It seems you want to hide the fields that allow input of height and width. Your initial solution doesn't seem to affect the dialog box, but what content gets saved. These are very different kinds of solutions. My answer assumes you're seeking to alter the image properties dialog box fields.
Based on this earlier question, I recommend adding the following configuration:
CKEDITOR.on('dialogDefinition', function(ev) {
var editor = ev.editor;
var dialogName = ev.data.name;
var dialogDefinition = ev.data.definition;
if (dialogName == 'image') {
var infoTab = dialogDefinition.getContents( 'info' );
infoTab.remove( 'txtWidth' ); // Remove width element from Info tab
infoTab.remove( 'txtHeight' ); // Remove height element from Info tab
}
});

How do I size a Firefox Add-on SDK popup/panel? Firefox Add-on SDK popup/panel too small

I followed the tutorial on creating a popup for an add-on in Firefox, and it worked great.
The issue I'm having now is that the popup it creates doesn't change size to fit the content I add to it. Instead, it adds scroll bars.
So, how do I change the size of a Firefox Add-on SDK popup to show all content?
You do have to deal with that yourself.
If you already know the desired size when creating the panel, you can pass the height and width as properties of the object to the Panel() constructor.
After a panel is created, its size can be changed by setting the height and width properties on it.
height and width values are numbers in pixels.
See https://developer.mozilla.org/en-US/Add-ons/SDK/High-Level_APIs/panel for a full documentation of how to use panels.
Though the tutorial and docs never say it, the height and width of a panel always defaults to the same small size.
To change it you can use the height and width parameters for the panel class.
If you want it to change automatically you can use this code:
//index.js
var panel = require("sdk/panel").Panel({
height: 200, //choose your default
width: 200,
contentURL: data.url("popup.html"),
contentScriptFile: data.url("auto_resize_popup.js")
});
panel.port.on("resize", function (size) {
console.log(size);
panel.resize(size.width, size.height);
});
...
//auto_resize_popup.js
var content = document.body;
var size = {};
size.width = content.offsetWidth + 2; //2 extra pixels get rid of scroll bars
size.height = content.offsetHeight + 2;
self.port.emit("resize", size);

Get div to adjust height with header content

I have a side bar that contains two divs. The first div may or may not have content, depending on what else is done on the page. The second div contains a long list of things and has a limited height, so scrolling is possible. I want to have the sidebar be as tall as the page, and I want the list container in the sidebar to be as tall as the sidebar minus the height of the header (which will change while using the page). I don't care about limiting the size of the header. The biggest is will get isn't anything significant.
Right now I'm just setting the height of the list container to be some number that is won't go over a maximized window height if the header div as as much content as it can, but this leaves an empty space at the bottom when the header is empty, and still doesn't work very well if the window is resized.
The layout is similar to this.
Is there a css solution to what I'm looking for, or will I have to use javascript and get window height/set div heights in pixels? I'm fine with either, it just seemed like there should be a CSS way to accomplish it.
If you're not opposed to using a little jQuery, here's a little code snippet that should help you equalize the height of the two divs, no matter which has more content. You can change it to your liking too.
var leftHeight = $(".left").height();
var rightHeight = $(".right").height();
var maxHeight = 0;
var div = "";
if (leftHeight >= rightHeight)
{
maxHeight = leftHeight;
div = ".right";
}
else
{
maxHeight = rightHeight;
div = ".left";
}
$(div).each(function(){
if ($(this).height() > maxHeight) { maxHeight = $(this).height(); }
});
$(div).height(maxHeight);
and credit where credit is due, this is an edit of a code snipped found at css-tricks.com
is this what you want?
http://jsfiddle.net/YWNyr/
CSS tips:
If you use 'absolute' positioning, width,height,left,top, etc... is relative to the first ancestor that has a "position" property other than "static", or the body if nothing is there.
for static menus, it is common to use 'position:fixed' as it will simplify scrolling issues
When using jquery its easier(and faster) to toggle a class than to change the DOM since that requires redrawing of the elements by the browser
-edit: for refreshing the sidebar size some javascript is necessary:
$('#headerAdd , #headerRemove').click( function()
{$('#sideContainer').height($(window).height()-$("#header").height());
} );
Try setting the height of your list container to 100%, and your overflow to scroll:
#listContainer {
height: 100%;
overflow: scroll;
}
This will keep the list in a scrollpane that reaches to the bottom of the page, no matter how large the header grows or shrinks.

Scaling and resizing flex component

I have custom flex component inherited from UIComponent (compiled, no source code access). It has fixed width-to-height proportions and it's scalable. If I set its width and height to 100%, it's trying to fit parent's size, but it keeps width-to-height proportion, so if it's proportion does not equal parent's proportion, there can appear empty space near this component when resizing parent.
What I need, is to fit my component completely to parent's size. Is there any nice way to do this? I could listen to parent's resize event, and play with component's scaleX and scaleY, but may be any better way exists to solve my problem (any property?). Thanks.
A great way is to use greensock's AutoFitArea.
Coding is as simple as the following
var area:AutoFitArea = new AutoFitArea(this, 50, 70, 300, 100);
area.attach(myImage, {scaleMode:ScaleMode.PROPORTIONAL_OUTSIDE, crop:true});
which would constrain whatever is inside do the given dimensions (300,100) from there on out, you can just change the area's width and that will figure it all out for you.
hope it helps
Personally, what I would do is have the component within the parent set at width/height 100%, then within the component itself, override the updateDisplayList function (which returns the unscaled width/height) and then resize whatever children you're trying to display depending on the width/height of this container. Something like this:
override protected function updateDisplayList(unscaledWidth:Number, unscaledHeight:Number):void
{
if(this._child!= null)
{
if(unscaledWidth > unscaledHeight)
{
this._child.height = unscaledHeight;
this._child.scaleX = this._video.scaleY;
}else{
this._child.width = unscaledWidth;
this._child.scaleY = this._video.scaleX;
}
}
}
Should do it.
Should the component keep its proportion? If not, you could just, as you said, listen to the resize event of the parent and set the width and height to the components values.
If the component should keep its proportion you could resize the background of your component so that it fits the parents size and resize the content of you component with its proportion seperatly.

Resources