Background
I know there are already logo and icon (difference is explained here).
The problem
Starting with API 20 ("L"? or maybe Android wear?) , there is now a new one, called "banner". Here's what the documentation says about it:
A drawable resource identifier (in the package's resources) of this
component's banner. From the "banner" attribute or, if not set, 0.
So this doesn't give much clues about what it is...
The problem is that I don't know what it is, and can't find any info about it.
What I've tried
I've tried finding about this on the Internet, but because "banner" is such a generic name, I didn't find anything interesting...
Of course, I've also tried searching about this on the documentation of activity (here and here), but didn't find anything...
The question
Where is it used for?
Is it for Android "L" or Android wear ? or maybe both?
Why has Google decide to make it?
Where can I read about it?
Are there any guidelines about it?
Depends on the answers, do you think it will somehow be part of the support library?
It's for Android TV.
From the l developer preview reference docs:
A Drawable resource providing an extended graphical banner for its
associated item. Use with the application tag (to supply a default
banner for all application activities), or with the activity, tag to
supply a banner for a specific activity.
The given banner will be used to display to the user a graphical
representation of an activity in the Leanback application launcher.
Since banners are displayed only in the Leanback launcher, they should
only be used with activities (and applications) that support Leanback
mode. These are activities that handle Intents of category
Intent.CATEGORY_LEANBACK_LAUNCHER.
This must be a reference to a Drawable resource containing the image
definition.
Must be a reference to another resource, in the form
"#[+][package:]type:name" or to a theme attribute in the form
"?[package:][type:]name".
This corresponds to the global attribute resource symbol banner.
You can also read a bit more about it here.
Essentially a banner is just a launcher icon for the leanback launcher. For example, if your app is compatible with both phones/tablets, and android tv, specifying a banner will let you have an alternate (rectangular) icon for the leanback launcher on android tv.
In this image, I specified the banner to be a red shape drawable. By default this will be your apps launcher icon.
I don't think it will be part of any support library, as it's specific to Android L on the TV. But to use it, you will need to be targeting L.
Related
I have the following problem:
There is response with json-array, which contain colors settings from the server. And from difference companies difference settings. There are next colors:
1) A main color, it serves to fill background;
2) A second color, which highlights a text, icons and buttons on the background;
3) The color, the darker the first - used in the allocation;
4) The color that is used for coloring the boundaries of the text and icons, if 1st color matches with the 2nd;
(It is the analogy with colors on iOS, because we write native applications and have on server)
And I do not know whether you can manually set these colors in Theme for the entire application , or this configuration must be stored in the form of a XML-code, i.e. we need to write a parser that generated an xml-string (it is a difficult way for me =))?
In addition - if I want to change the Theme of entire application, how can I do this better programmatically? One way I know - all my activities inherited from class, which extends a class Activity, and in this class prescribe and change the Theme. Maybe there are other ways? But the main question about the generation of style.
Sadly, there is no clean and direct way to do this. The theme is part of the resources which are generated at compile time. And Resources.Theme is a final class, so it can't be overridden to do custom behaviors.
So the options you are left with are all bad:
Brute-force change each and every visual property of every widget affected by the customer theme. Yuck.
Dynamically create HTML pages that can be read into a WebView and used as the UI instead of Android widgets. You will probably have to write a lot of canned JavaScript code that will be part of this web UI.
The cleanest, but nearly impossible way, would go like this: As each customer gets registered in your corporate database (along with their color branding scheme), your build process generates a new expansion APK with a theme for that customer, then uploads it to Google Play. Your app would need to know to look for an updated expansion APK and get the user to download it (which may not always happen), then your JSON response would give you the customer name or whatever you need to determine which theme to pull from the expansion APK. Finally, your app would set the theme on the Activity for your white-label UI. So many things would have to happen correctly that it would be a minor miracle if your user saw your customers' corporate branding colors. But just thought I'd mention the idea for inspiration.
So I modified the Mediarouter source to be dependent on ActionBarSherlock rather than AppCompat. However, now the callback from MediaRouteAdapter onDeviceAvailable(...) is not being called.
Any ideas on how to get this to work?
I don't want to leave the cast button always visible. Rather, I want to use onDeviceAvailable(..) to only make it visible when a device is available.
I found a hack on how to fix this.
If you use appcompat, the cast icon will only be visible when you have a chromecast device in your network, based upon your implementation of onDeviceAvailable(...).
However, if you use ABS, the onDeviceAvailable(...) method is not called when a chromecast device is available on the network. So in order to see the cast icon, we must set it as always visible.
So the issue is that the cast icon is always visible (when you set visibility to visible or when you add it to your actionbar).
HOWEVER:
The MediaRouter has different view states. One for when a cast device is available and one for when there isn't one available.
The Mediarouter library consists of drawable pngs that are the icons for when a device is available or not.
Just replace the one for which 'no route is available' with a blank resource, or anything that suits the app.
When a device is available, the correct cast icon will show, and when not available your custom resource will show (blank if the resource is a blank view).
Here are full details on how to obtain the mediarouter source code, and how to fix this: http://www.droidorbit.com/2013/10/mediarouter-and-actionbarsherlock.html
This is a question for Android developers but it is not a programming-related question as it affects nothing but the developer.
What conventions are the most commonly used when naming various resources like colors, drawables and strings and etc?
I have no doubts naming my layouts activity_main or layout_secondary. However, I have always doubts when naming resources mentioned previously. I never know whether I should name these resources after their use or the content. For example:
Color: dark_blue vs text_highlighted
Drawable: blue_gradient vs top_bar_background
String: welcome_to_app vs first_time_prompt
Is there any community-created resource for good practice?
Naming is pretty much personal preference. The name is perfect as long as the name indicates what the functionality of the defined thing is. Also you and any other developer using these definitions should know how what the names mean and which definition to choose. Quite easy if you are consistent with names throughout the project.
For example dark_blue is obviously a blue color while text_highlighted is the color of highlighted text. The name you should use depends on what you need: if you want to classify colors by their name take the first, if you like to abstract from the actual color take the second. For general layouts using text_highlighted will often make more sense since the actual color does not matter and the functionality (text highlight vs text regular etc.) is more important. In this example choosing between text_highlighted and text_regular is a lot more obvious than choosing between color_light_blue and color_dark_blue although they could refer to the same color. The name can help prevent errors.
Android uses prefixes for names in [android.R.drawable]
(http://developer.android.com/reference/android/R.drawable.html) for example:
btn_ for button graphics
ic_ for icon graphics
ic_menu_ for menu icons
ic_dialog_ for dialog icons
stat_ for status icons
The schema is certainly not perfect but the advantage of using prefixes that start with the most generic classification is that you can use code completion to search for specific items step by step. So color_blue_dark could be better than dark_blue_color, at least if you consider the color classification more important than the dark / light classification. The same applies to first_time_prompt. If you have a lot of prompts it would make sense to name them prompt_first_time, promt_other_time, ... If they can be classified by an activity for example that could be used as super category: mainactivity_prompt_*, secondactivity_prompt_* so you know where they belong to.
Android SDK will be a good place to start for the good practices. You can open up any sample code in the SDK and go through the code and see the variable names.
I usually name assets like colors and pictures for their content, but I will name a style or multiple state drawable for it's function.
for example:
button_On.png; button_Off.png; button.xml
That way if I want to use the same resource in multiple places it does not get confusing.
For example using a color as a text color in one style file and a background in another style file.
I am developing an android using the API Google Tv Addon, i wanna use the screen qualifiers no touch, i created a folder under /res/ called layout-notouch, i named my layout test.xml, in my activity when i put setContentView(R.layout.test) the application crash. how could i use this screen qualifier. Or otherwise, could i set qualifiers programatically. you can take a look here enter link description here
You can use layout-large-notouch for layout and drawable-land-xhdpi for drawables to target Google TV.
I figured out that the layout-notouch is not working.You can find the google bug report at this links https://code.google.com/p/android/issues/detail?id=20087
Some people are suggesting to use resource qualifiers layout-tvdpi-notouch (720) & layout-xhdpi-notouch (1080),layout-large-notouch.
But not sure the suggestion is working.
I'm not entirely sure about what I'm about to say, but it seems to me that "notouch" qualifiers will not work because current Google-TVs support some sort of touch. You have a trackpad that acts as a mouse and you can click on things, simulating "touch" events.
If in the GTV emulator you edit the avd settings, you can specifically declare the "touch screen type" as "notouch". Then, if you run your application under those conditions you will see that the "notouch" qualifiers work. This means that by default "touch-screen type" is set to "touch" instead of "notouch".
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.