Android :: Configuration Change - Width And Height
Jul 25, 2010
What happens to the width and height params declared in LayoutParams on configuration change? E.g. if I have an ImageView declared with,
new LinearLayout.LayoutParams(30, 40);
On Configuration Change, does the width become 40 and height 30?
Every time that I want to do a Layout, I'm getting a black layout preview then I can drop stuff on it, that's ok, but how can I change the size of that blank surface (xml). The question came because I set a folder layout-large and then when I add a new layout.xml to that folder it came with the same size, as a layout-normal.
I want the second ImageView to have the very same size of the first ImageView so that it resizes the pictures I set in the second view (header_avatar) to the same of the first view (@drawable/icon). Is this possible or do I have to do it programmatically? Cannot I reference the first view's width and length on the second view?
is it possible to set dynamically(from code) width and height of gridview, if so what r methods. I want to keep my gridview changeable at run time in width and height. ( if this is not available; Is there any other solution?
Can you please tell me how can i set the width and height of an ImageView programmically in java code (not layout xml file)? I tried setMinimumWidth/setMinimumHeight, but that does not work. I have looked at the view in HierarchyView, it still said the width to be 80 and height to be 100. And that is not the value I set.
I am working on layout in android XML in which I would like to set a buttons height to match it's width when setup to fill parent. Obviously this number will change based on screen size, so I cannot use a set pixel size. Can someone help me with getting the button width based on screen size and then passing that to the height setting?
I have a problem creating a custom view for an Android application. My custom view wants to use if permitted the maximum screen width. I couldn't find any way to retrieve this value. Can anybody point me to the right method?
One of our views has a ScrollView as its root layout. When the device is rotated and onConfigurationChanged() is called, we'd like to be able to get the ScrollView's new width/height. Our code looks like this...
I have a task to parse thumbnail images and to set it on grid view,where url image content to be in different height and width(some images to be 60*60, or 110*80),how can i set images in grid have uniform height and width.
I want to get the width and height of my device to know what type device it is ie QVGA, HVGA ,WVGA.. Also i need to adjust some layouts according to width and height of the screen.
I tried following methods but its not working.
All these methods return wrong width and height for the 240x320 devices namely Samsung Europa and Alcatel which i have. Width = 320 Height = 240.. This is wierd as some of the critical functionality is getting hampered .. I think this is really a basic thing which shd be correctly provided. Please help me with this issue .
I am writing an android application that has 3 views one below the other. Each view has to be of equal height, depending on the screen size. Each view occupies the full width of the screen. How do you specify in the layout xml that the view has to take up 1/3rd height of the device display height? What would be the appropriate layout to use in this case?
On a Nexus One (for example), the camera application is able to capture H.264 video at 720x480 (the "High" quality setting). However, when using the MediaRecorder API, it always seems to capture at a fixed frame size of 320x240.
I would expect the setVideoSize() method to control the frame size (as in the prepare fragment below), but it appears to have no effect (using Froyo 2.2 Android SDK).code...
Discussions on the android developers list seem to indicate this is a long standing issue. Can anyone advise how the frame size can be controlled, or if it is possible at all with the current API?
Flipping between landscape and portrait is causing me a problem with dialogs that are active at the time of config change. The dialogs survive (which I think is good), but I have the problem that some of my dialogs contain dynamic content which would need to be refreshed in the dialog views. All that content disappears from the dialog views after the config change.
I thought it would be easier to do a dismissDialog() on restoration in onCreate(), letting the user press the button that shows the dialog. I successfully save and recover the dialog id, but when I attempt to dismissDialog(id) I get an IllegalArgumentException: no dialog with id 1 was ever shown via Activity$showDialog. Ok, so that doesn't work, and I still have that messed up dialog up on the screen that I want to get rid of. How can I do that? Are there any other reasonable alternatives?
My app creates and shows an AlertDialog which accepts input from the user (the user needs to type some text into an EditInput).
With the AlertDialog on screen, if the user opens up the keyboard on the device, then the app's OnCreate and OnResume methods are called and my AlertDialog promptly disappears from the screen ... not the effect I was hoping for!
I thought that perhaps I needed to override the Activity's onConfigurationChanged method, but despite having the following in my Manifest:
I want to change the key width in keyboard at runtime. The constructor of class Keyboard only accepts the layout resource ID. I tried setHeight method, but it didn't work obviously when I checked the code of Keyboard. Any solution? Do I have to implement my own Keyboard
I am trying to set a RadioButton as checked/not checked through code. It is working the first time I set it, but the second time, the code does not set the button. Here is the relevant part of my code. I have commented on the problematic part. code...
I'm trying to make a timeout gauge bar animation effect:The width of a lengthy colorful bitmap image is decreasing, but not x-scaling.so the image looks not changing and the visible area shrinks.I couldn't find the sole ImageView clipping or masking support in android.then changing the shrink_box's width will clip the portion of the still_image.But I failed to change the width of the view smoothly.I tried to change the LayoutParam.width in applyTransformation() but got an Exception, it seems not allowed. How can I make an Animation that changes the width of the view. OR is there a proper method to achieve the above effect?
All works fine, however I want the gameboard to appear as square. So I need to resize the board at runtime to put it in the center of the screen and make it square. I tried many options without success.