layout lost after theme - Java for Android App Development

I want to make an activity to look like the PIN screen . I have a table layout and it looks fine (pic 1), but i want to have as background the wallpaper of the phone.
this code :
Code:
WallpaperManager wallpaperManager = WallpaperManager.getInstance(this);
Drawable wallpaperDrawable = wallpaperManager.getDrawable();
gets the wallpaper streched.
so the only way to have the right background is to theme that activity using android:theme="@android:style/Theme.Wallpaper.NoTitleBar".
But then my layout is lost (pic 2).
Can anyone help me ?

Don't use a style.
Just set the layout background, of your activity layout xml, to the wallpaper drawable.

How are you setting your table layout's background?

You set the root layout background using android:background attribute.

Related

[Q] change background image

how do you change the background image from within the java code (i.e. not within the layout.xml)
hyperbyteX said:
how do you change the background image from within the java code (i.e. not within the layout.xml)
Click to expand...
Click to collapse
Change background image of what? Wallpaper, button...?
The wallpaper
Sent from my GT-I9000M using XDA App
In your layout file, give your layout an id:
<RelativeLayout
android:id="@+id/myLayout"
.......
>
Then in the activity code:
RelativeLayout rl = (RelativeLayout) findViewById(R.id.myLayout);
rl.setBackgroundResource(R.drawable.myNewBackground);
Or are you asking about the homescreen wallpaper for the device?
Lakers16 said:
Or are you asking about the homescreen wallpaper for the device?
Click to expand...
Click to collapse
I think that's what he meant.
Code:
getApplicationContext.setWallpaper()
should do it... But check the documentation for proper syntax.
that only lets me use bitmaps. How do I set it by resource (e.g. "R.drawable.image4")?
Make it a bitmap then:
Bitmap bmp = BitmapFactory.decodeResource(activity.getResources(), R.drawable.img);
activity.getApplicationContext().setWallpaper(bmp);

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] How do I set a color to be transparent ImageView

I have a ImageView with a bitmap on on top of a FrameLayout. To get this bitmap I converted a png w/ transparent background to bitmap. So all the transparency turned into black. How do i set that black to be transparant.
Thankyou
could you be more specific to help you. i can't get your question probably please bare with me. thanks
Only by not using a bitmap. Why did you convert the png (that supports transparency) to a bitmap (that doesn't support transparency) anyway?

[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]
}

[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