Precise image rendering in AppWidget - Java for Android App Development

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.

Related

Android Expert Required

I want to develop an app that puts a white line grid on a black background.
The grid has 3 columns and 3 rows
There is a 10% border around the grid.
The first column takes up 50% width
The second column takes up 20% width
And the third column takes 10%width
None of the columns expand or contract, they always stay the same size.
Each row is the same height.
If you click any cell, a keyboard appears on the screen allowing you to input data into the cell.
Is it possible to do this white line grid in Android?
If yes, how does one do it?
Best regards
RedTopBox.com
anyone know
Hi All
i have not received any replies.
Can anyone help please
I think it is possible. Do you have a fixed number of rows? is it small? if yes, you could directly use LinearLayout with orientation set to horizontal for each row. There you have android:layout_weight which you can use to play with the different widths you have. For the table borders, just add a View, with a background color of your preference, again use layout_weight if necessary.
If you have too many rows, or you would prefer another approach, you could use TableLayout, and for each row a TableRow, and in the same way use layout_weight for the width. For drawing the borders you could do it in this way: http://www.droidnova.com/display-borders-in-tablelayout,112.html
TableLayout has different parameters like shrinkColumns, or stretchColumns, which you will probably would need, but I am no expert on this, so you would need to play with them.
For displaying a keyboard when the user press on each element of the table, you could have a editText on each, so this would be automatically.
BTW I recommend you asking this type of questions in stackoverflow.com, and tag it with android, there should be more capable people than me to help you with this particular case.

[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

windowIsFloating=true & window size

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

[Q] Why does TouchWiz not scale wallpapers properly?

(The following applies only to the original TouchWiz launcher, modified to enable scrolling wallpaper.)
I've noticed this lately - TouchWiz will quite frequently ignore your specific scaling settings in whatever wallpaper app you're using and crop out parts of the left and right sides of the wallpaper so that you don't get to see everything in full. It even does this with its own default wallpapers! Here's the proof:
(Original wallpaper (pic reduced to half its original size for easier viewing).)
(How the leftmost and rightmost sides look on the default launcher, default 5-home-screen setup, using Samsung's own wallpaper picker.)
In case you're wondering, the amount of home screens has nothing to do with it. All adding more does (and from this 5-screen default you can only add 2 more anyway) is slow the scrolling rate down in order to display just as 'much' of the wallpaper as before.
Furthermore, I've seen it screw up the scaling in similar ways with programs like QuickPic, ES File Explorer, Wallpaper Wizardrii and what have you.
The only workaround so far that I've found to getting it to display the whole wallpaper without leaving bits off of the edges is by resizing the wallpaper's width to 1680 pixels (so for instance, 1680x1920) and using the "Image 2 Wallpaper" app from Google Play, telling it to not resize the wallpaper.
I'm hoping this is something that can be rectified by modifying the SecLauncher APK, or the SecWallpaper APK, or whatever. An alternative launcher shouldn't be the only solution really!

[SOLVED!] [NST/G] How to get rid of default wallpaper?

I'm working on setting up a second NST and this time I want to arrange the launcher a little differently. I'm using ADW EX 1.3.3.9 and it seems to have picked up a default wallpaper from somewhere on the device (screenshot below). I can't find any way in ADW to do anything with wallpaper and I can't locate the image that's being used anywhere on the device. I don't want any wallpaper at all.
Can anyone point me in the right direction?
Edit: That was almost too easy...once I found the right ancient app. Then I created a 800x600 white png file and chose it for wallpaper. Magically it replaced the mysterious "n" image! I've attached a copy of the useful app
I have a simple (and boring) app for setting wallpaper.
You get a choice of black, white or aqua.
Note that wallpaper is usually larger than the screen size due to panning.
The only way to find out how large is to ask the system.
Code:
WallpaperManager manager = WallpaperManager.getInstance(this);
int width = manager.getDesiredMinimumWidth();
int height = manager.getDesiredMinimumHeight();
Wallpaper-1.0.apk is in the signature.

Categories

Resources