I am working on a small application which should be represented by an AppWidget.
The AppWidget should look like many other widgets on my HTC Desire. Most of them consist of an icon and a title below the icon. The title always looks identical, it is white text on a black rounded banner. I have not found a way to get this layout without painting all by myself. What do I have to do, to get the app title shown below the AppWidget?
Thank in advance,
Wolfgang
Per a previous answer here this is actually discouraged by the Android UI guidelines: An App shortcut has such text below it, and it may change in future Android releases or in custom skins such as HTC Sense or MOTOblur. A widget should be a wholly contained graphical element without a text label below it. You need to find a way to make graphics / text in your widget which are self identifying to the user.
Related
I have five background images which are displayed back to back after a certain time interval. I have to add a page indicator for backgrounds so that user can know which background is currently selected. The user should also be able to select next backgrounds using tv remote.
I cannot compromise tv look and feel for rail and its contents which are displayed on the screen.
I also need to resize background image. I do not want the image to be full screen and its size should cover half portion of tv only. Background image should overlap first rails content to an extent.
I am not getting any such sample or blogs depicting customization of background. Any help would be really appreciated..!!!
Try to use layout themes for TV.
Android Themes can provide a basis for layouts in your TV apps.
You should use a theme to modify the display of your app activities
that are meant to run on a TV device. This section explains which
themes you should use.
Style and Themes can be:
A style is a collection of attributes that specify the look and format
for a View or window. A style can specify attributes such as height,
padding, font color, font size, background color, and much more. A
style is defined in an XML resource that is separate from the XML that
specifies the layout.
You can see samples codes as well from the documentation.
I added two fragments inside my Activity. One fragment is for displaying background and indicator. While another fragment is extending BrowseFragment of leanback library, and is used to display rails/headers as is depicted in tv app android sample which is generated via android studio.
Tried all sorts of different ways to do this but not matter what view I apply an elevation to (such as android:elevation="10dp") it does not render correctly on a Home Screen Widget.
Is this a known limitation, that home screen widgets do not support elevation. I am running this on an Android L device so its should not be a compatibility issue.
If this is impossible I figure I could use 9-patch or layer-list drawable to achieve a similar but not as good effect.
I've played with all widgets I have on my phone (both with Nova Launcher and Nexus 5 stock launcher, which is Google) and none of them have this feature, even Google apps (excluding Google Now!).
I've added app:elevation="10dp" on my widget and I think that it is not possible to have this feature on Widget directly, without playing with code and fantasy.
If you really want a widget that include elevation design, just "copy" the style of Google Now widget.
I suppose that they have a transparent layout (the black parts on image) wich contains another layout (grey) with elevation and grid filled with CardView with elevation too.
Let me know if you want an example code.
I'm currently creating a custom status bar notification to notify the user of progress through an event. I have the custom notification working fine, but having a progress bar requires that I pass my own set of RemoteViews to the notification through the contentView field.
This is fine, except that I want to be able to base this layout off the default one. I am targeting API 10, and so it must work with both Gingerbread and ICS. Gingerbread is fine, as I can just put an icon on the left of the layout and the notification fits in with other default ones. In ICS however, the notification icons all have the striped square on the left that contains the icon (it effectively forms a UI "handle" to help indicate that the notification can be swiped to dismiss it).
Does anyone know how I can either get the default layout in code, and then edit it (this is hard with remoteViews), or somehow get access to default layout view (probably during runtime), then copy it, and substitute the notification text for my progress bar?
I have seen examples where people have created a notification and cloned the layout, but to do anything useful with that you have to know quite a lot about the layout. I would rather get the layout files from the android versions you are interested in. Here you have the JB one, you should not have any problems finding the others.
If the only reason you want a custom layout is to get a progress bar, you could look at
NotificationCompat.Builder.setProgress(). It'll be easier than playing with custom notification layouts. If you do decide to use custom layouts, they changed only slightly between API v14 and API v17, and I have no idea what they're like for Honeycomb but they're unlikely to be much different. What that means is that you should be able to use one custom notification layout in a layout-v11 folder, and one in your default layout folder, and you'll catch most cases (except for the icon background from Honeycomb upwards, I haven't gotten that part working in my own custom notifications yet) and only have to maintain two different layouts. See the answer above for the location of the default layout; note that it's called status_bar_latest_event_content.xml in earlier versions of Android.
Since setProgress() is available from Honeycomb upwards at least, and it looks like it works on earlier versions too (the docs don't say otherwise), then you should probably use that if you don't have any other custom requirements.
On my Samsung Galaxy, application icons displayed on my Home Screen often don't match those displayed on the Applications Menu.
Firstly, I want to know if this is peculiar to Samsung/Galaxy (or some subset of Android phones), or if this is across the platform? Secondly, I'd like to know how to set this up in my Android project.
To illustrate what I'm asking, please refer to the following image:
Icons 1 and 2 are typical of a lot of third-party apps: on the Home Screen the icon transparency is honoured, but on the Applications Menu the icon is over-layed onto a button graphic. On my phone the latter is more-often-than-not a dirty-green, radial pattern.
Some apps have over-ridden this behaviour, however: icons 3 and 4 show that MapQuest has been able to specify a different base colour for the button (same radial pattern, though); and icons 5 and 6 show what appears to be a complete replacement of the button image or Application Menu icon.
Can anyone explain what I need to do to specify both forms of the icon in my project?
Thanks, in advance.
That particular effect is part of the Samsung Homescreen UI. It does something similar on the Galaxy Tablets.
icons 3 and 4 show that MapQuest has been able to specify a different base colour for the button
I don't think that they specified that I imagine that it is either luck of the draw(on Galaxy Tab there are many colors blue,green, orange, pinkish, etc...they don't appear to have any sort of pattern for which icons get which color), or it can tell that their icon is green also, and because of that it changes colors so that you don't end up with a green icon on top of a green backdrop.
and icons 5 and 6 show what appears to be a complete replacement of the button image or Application Menu icon.
I don't think they had control over that. I think it is just another one of the possible backdrops that the system uses.
Can anyone explain what I need to do to specify both forms of the icon in my project?
As far as I know you can't the backdrops are up to the 3rd part home/launcher replacement app. In this case Samsung's (but there are other home and launcher replacements on the market that could also use an effect like this if they wanted.)
Thanks, Tim - further playing around has revealed more...
As a result of refactoring my package names, I ended up with two copies of my app (with identical icons) on my Applications Menu.
As Tim suggested might happen, the second icon has a different, apparently randomly allocated, background. It would appear that the button colour is unrelated to any colour in my icon, however, as the same icon got allocated a different background.
I've seen references on how to SET system colours, but I need to find out how you GET them - how do you find out what they are?
On the Samsung Galaxy S for example, the tab views, ListView highlights when you select an item, and the Summary text line on the preference screen are all blue.
There are many apps which immitate this style and I want to do the same. Obviously I cannot just hard code and set the colour to Blue, as other handsets use different colours.
The question is, is there a way to programmatically find out what colour the Preference Screen Summary Line, Tabs, or ListView selections are, so that you can then set that against a TextView elsewhere in your app?
How do I get the android system colours?
There is an answer to this question, but it is probably not the one you wanted to hear. There is no way to reliably do this. The "selection color" is actually part of a nine-patch image, which is provided on a platform specific basis. Some use the standard orange color, some (Sense) uses green, and others use red. With an exhaustive list of these you might be able to create a mapping from hardware to color, but this is not very effective because new hardware comes out all the time, and some of these phones allow sense to be uninstalled.
The only real thing you can do is to make your buttons consistent within the application itself, which is a hard enough task by itself. If you really have to have a custom item with a selection color (which is common enough), then my advice would be to copy the button resources from the platform of your choice (I like the default sdk resources myself) and then manually set them throughout your application. This way they will always look the same no matter which platform you are on, and so will always match your custom views. Note that this will require you to do more than just buttons. Dialogs and menus also will need to be modified, which is possible, but hard.
Really this is a flaw in the way Android was designed, and it causes a lot of us grief. I wish I had a better answer for you, but I think this is the best we've got.
You can specify colours to elements in your XML layout using the #android:color system variable:
<TextView android:background="#android:color/white" android:textColor="#android:color/black" />