I want to use the user's current homescreen as an element of an app, including their icons and layout. I do not expect it to be dynamic, just a static image of their screen upon which the app can act. The "Cracked Screen" app does this like I'm thinking.
In researching, I've found ways to grab a screenshot (requires root) or grab the current wallpaper (doesn't include icons), but nothing yet about this particular issue.
Any ideas? Thanks!
Use the translucent theme. Set it in your AndroidManifest for the relevant activity like this:
<activity android:theme="#android:style/Theme.Translucent"
...>
This sets the users homescreen with it's icons as the background of the activity, your views float over that. Alternatively you can use #android:style/Theme.Translucent.NoTitleBar if you want to hide the title bar additionally.
Related
As I have been seeing out there, most of Android Widget preview images follow a design pattern which contains a simple image Centre-Vertical and left aligned with the same image's big grey shadow below it. See the Android Contacts Widget image:
If the user wants to add the widget to the screen dragging it, the logo will be the only image object which is going to be dragged and not its shadow. Trying to emulate this kind of images for my widget, I have created a simple PNG24 with a logo and its shadow below, but when dragging it both the logo and the shadow are dragged, and not just the logo as the mentioned widgets do.
How do they do to achieve that behaviour?
The design pattern you are talking about it's only applied to bookmark widgets, and its done automatically.
This is, when your activity uses the intent filter ACTION_CREATE_SHORTCUT, the launcher app adds a widget to its widget list and uses the android:icon attribute of that activity to create that design. If you don't provide an android:icon attribute in that activity, it will use the application icon
You can easily see the expected result without really implementing the functionality by adding:
<intent-filter>
<action android:name="android.intent.action.CREATE_SHORTCUT" />
</intent-filter>
to one of your activities.
I'm designing a custom Android 4.0 (ICS) device for special purpose.
One of the things I'm looking for is a way to make the Android Launcher, when other activities were previously running, show the last running activity as a transparent, dimmed background, with the launcher icons and widgets on top.
What I'm looking for, is something like this: How do I create a transparent Activity on Android?, except as a modification to Launcher2. I guess I can apply a similar style to the launcher as proposed in that SO, but what about the wallpaper?
AFAIU, the wallpaper is rendered by a separate service, and I still want it rendered if there are no other activities behind the launcher.
Any tips?
I figured this one out myself eventually. It turned out pretty simple.
Just modify the theme as suggested in the mentioned SO-article, and simply change inheritance from the Wallpaper-enabled theme.
Also, there were a small code-snippet that was reactivating the wallpaper. Switch that out, and I've now got a transparent launcher, that shows what's going on behind it.
I know that we can set it through manifest file using android:icon attribute.But how can we set it in java code?
It doesn't make sense to set it programmatically, the launcher has to display the application icon when the application isn't active.
If you take a look at How to change an application icon programmatically in Android?, you will find a comment, which links to this sample code in the Android developer API demos: LaucherShortcuts.
It seams that the Activity can create a LauncherShortcut, which can have a different icon (see function setupShortcut()). If you want the user to select the Icon, you have to display a list of icons when creating the shortcut. But again, it is a shortcut. In the list of application the original icon appears.
I dont think the launcher icon can be set programatically.
I want my activity to take smaller area of the screen e.g. toast doesn't cover all of the screen, it is just shown over other things and rest of the contents can be seen behind the toast. But it's a dialog, and I want my screen to be shown above other things e.g. above Home Screen. Below is the idea that is in my mind.
Kindly, guide me if it is even possible. If possible then show me the right path.
Thanks.
make your activity theme as translucent.
add the following line in your manifest against that activity:
android:theme="#android:style/Theme.Translucent"
so that you can see the background things add the view to a LinearLayout with android:alignParentBottom=true.
Latest versions force a style based on Theme.AppCompat. Use this to create a quick dialog style based activity.
android:theme="#style/Theme.AppCompat.Dialog"
you can use custom dialog box.
Check this and also this
you can design you layout transparent so view main activity also.
I want to have a "change theme" feature in my app. If I call setTheme() in onCreate(), there is one problem.
The moment after I launch my app, a plain white background appears for a second (because I have set light theme in the manifest). After that, the complete layout of my Activity is displayed - it is either with white or black background, according to user's theme preference.
Is there any way I can change whether white or black background appears after launch?
Make sure you call setTheme() in onCreate() BEFORE calling setContentView(). Then if you want to dynamically change the theme again later, you should simply restart your activity.
If you are adding a theme to the entire program than you could start by doing:
In your manifest you add to your application tag that you are using a theme.
<application android:theme="#style/mythemename">
Then look at Theme XML to make sure that you have what you need declared in the appropriate places.
If it is just for a particular action you could add the activity tag
<activity android:theme="#android:style/Theme.propertyname">
You can also, if you want your theme to just change the background color, follow the same pattern with either the activity or application tag (what ever one you are using) and set the item name "colorbackground" to what you want.
You can also use Theme XML and remake what you want in your current theme and call that your custom theme using the method above.
I hope this helps and if not please let me know so I might be able to help better in the future.
Another way would be to have a kind of splash screen which will check for a preference variable for example and then decide whether to use the light or the dark theme. This way you could also use XML layouts.
EDIT: Yet another way is to have the all the layout defining stuff in the onCreate() method and then just trigger the onStart() method when ready.