windowIsFloating=true & window size - Android Software Development

I'm developing an activity with a floating main window (e.g. windowIsFloating=true in the activity style). Unfortunately, within a floating window my layout (using fill_parent) is not expanded to the full screen size; fill_parent behaves like wrap_content instead. I suppose floating windows are not automatically sized to the regular/maximized window size.
To circumvent this problem, I use the following code to add the layout to my window:
View view = getLayoutInflater().inflate(R.layout.main, null);
setContentView(view, new LayoutParams(width, height));
This renders my layout correctly. However, how do I find out the correct width and height, taking into account decorations like the status bar? According to the documentation, floating windows automatically get the FLAG_LAYOUT_INSET_DECOR set, causing the WindowManager to report inset rectangle needed to ensure the content is not covered by screen decorations. However, I can't find any documentation on how I can retrieve this inset rectangle; does anyone know this?
I've tried many options (all called from my Activity onCreate method), but they all either return non-usefull information or the full screen size, not taking into account the status bar height:
WindowManager.LayoutParams lp = (WindowManager.LayoutParams)getWindow().getAttributes();
Rect rect = getWindow().getDecorView().getBackground().getBounds();
getWindow().getDecorView().getGlobalVisibleRect(rect);
getWindow().getDecorView().getHitRect(rect);
getWindow().getDecorView().getLocalVisibleRect(rect);
getWindow().getDecorView().getWindowVisibleDisplayFrame(rect);
I'm now using a work-around that simply substracts 38 from the height to account for the status bar, but of course that's not a real solution.
Also, does anyone know whether it is possible to hide or overlay the status bar when using a floating window? Setting windowFullScreen=false only works correctly for non-floating windows.

I believe you can set the theme in xml to remove the status bar in your app.
<activity android:name=".YourClassName" android:theme="@android:style/Theme.NoTitleBar"/>
And
<activity android:name=".YourClassName" android:theme="@android:style/Theme.NoTitleBar.Fullscreen"/>
From something awesome

O yea that is in the AndroidManifest.xml
From something awesome

Related

[Q] using getSurfaceFrame to get display width/height?

So I'm trying out making a live wallpaper and I'm using the sample code provided in the SDK for the cube live wallpaper
I wanted to use this code to get the height/width of the display
Code:
@Override
public void onCreate(SurfaceHolder surfaceHolder) {
super.onCreate(surfaceHolder);
Rect frame = getSurfaceHolder().getSurfaceFrame();
float width = frame.width();
float height = frame.height();
// By default, we don't get touch events, so enable them.
setTouchEventsEnabled(true);
}
and if you're wondering about the context of the code, just look at this sample
Unfortunately, when I run this code, the width and height return as 0, though if I put this in onVisibilityChanged, the correct values are returned, why is this and where should I put it?
Also, when I do get the display width/height, it includes the real estate behind the notification bar as well. Is there a way I can get the width/height area of everything excluding the notification bar?

[Q] Resize a linearlayout in an appwidget from code

is it possible? I have created a unique sort of clock as an AppWidget that has horizontal bars that should indicate minutes and hours. How could I change the width of the LinearLayout used as a bar from the onUpdate() method? I tried RemoteViews but that Views seems to lack a setWidth() method...
appwidgets are unlike anything else in android. they cannot directly alter, add, or remove items from a layout. the only thing that can be altered is text in a textView, the visibility of a view inside the layout, and the value of any of the views inside the layout, like int, bool, float, images, progress bars.
you can however change the view entirely, as in change to another layout.xml
you'll have to be creative to be able to find a way for your widget to change. i think the setViewVisibility() method could help. if you layout every piece that you need and selectively set their visibility based on the state of your widget.
here is a kinda related topic
http://stackoverflow.com/questions/...-dynamically-in-an-android-widget-api-level-3
Hmm, so if I would do 60 linearlayouts and place them next to each other, and say the clock is 13:30, I set the first 30 layouts visible? How would that many views affect performance???
Not sure. Probably wouldn't be good with that many.
This is where you'll have to be creative. Might be good to have one image view and have a bunch of images of the bar at different stages. Though that would require alot of images.
Just remember you can change the content of a view but you cant add another view "on the fly". Its a tricky thing to deal with in an appwidget. Ive been trying to make a widget that displays a tag cloud of your gmail inbox and ive had to use a textView as a wrapper to display the generated html for the cloud instead of adding new textViews for each tag.
From something awesome

Precise image rendering in AppWidget

Since SDK 4.2, Google has a way to retrieve the dimension of an existing appwidget. You can use the bundle in onAppWidgetOptionsChanged callback to retrieve the upper and lower bound of the widget. But I need to scale a bitmap precisely to fit the widget. Anyone knows if it's technical possible in existing SDK to get the pixel-correct dimension of the appwidget?
What's more, I found that the stock launcher in JB (as well as Apex) returns incorrect values for the upper and lower bound. For example, if the widget is in portrait, it may return a rectangular dimension in landscape. Nova, however, doesn't has this issue.

[Q] Overlay list item when it's pressed

I want to add a layer when list item's pressed. The layer will overlap any object in list item (imageview, textbox, layout background, ...). It's exactly like Google apps (Play, Youtube,...), when you press or hold an item, you can see it. My app has some complex list items, so using background seletor is not good enough.
Thank you.
Looking at the play en youtube app, it seems like they only change the backgroundcolor and don't add an overlay.
If you have created your own row layouts and added them to the list, you can get the most outer viewgroup from this layout in your onItemClicked method.
Just change the background of this viewgroup.
Code:
onItemClicked(View v) {
[INDENT]v.setBackground(your background);[/INDENT]
}
If you do want an overlay instead of another background, you can wrap your row layout in a frame layout with an invisible overlay. Then just change the visibility in the onItemClicked method.
Code:
onItemClicked(View v) {
[INDENT]View overlay = (View) v.findViewById(R.id.overlay);
overlay.setVisibility(View.VISIBLE);[/INDENT]
}

SlidingUpPanel, thin line sliding panel under mapfragment

I made sliding panel using this repository: AndroidSlidingUpPanel-foursquare-map-demo
However, it contains one bug which is not covered anywhere.
When I touch anywhere to expand panel (listview) works well, but while I'm trying to expand it by holding a top of a list view (blue line on screen2) panel hide under the map (framelayout) (screen3)
How it's even possible that this blue line hiding panel under mapfragment and rest of listview expand it well?
Please give me just a hint how to fix it?
Please look at the screen:

Categories

Resources