com.salesforce.android.knowledge.ui.KnowledgeCssProvider |
Interface for providing CSS to Knowledge articles as they are displayed to the user in a WebView.
This interface allows you to provide CSS that will be applied to every article, and also to provide CSS for each individual article. Internally, the CSS you provide will be embedded into the head of the article's HTML. Please note that this API expects CSS as a String and not a file path or URL. If you have CSS from multiple sources then you must merge them into a single String. You must pass your instance of KnowledgeCssProvider to yourKnowledgeUIConfiguration
object
via setCssProvider(KnowledgeCssProvider)
before launching Knowledge
UI for it to be used.
This interface does not specify how CSS is sourced. We recommend loading CSS from disk
and reading the contents into a String value as early as possible, as this is a UI blocking operation.
Below is a list of CSS selectors relevant to the base HTML for Knowledge articles. You can use these in your custom CSS to change how articles are rendered.
CSS Selector | Description |
---|---|
h1 | Used for the title of the Knowledge article |
p.modified_date | The modified date paragraph shown under the title of each Knowledge article |
section | Used to contain each Field present in the Knowledge article. |
section > p | Paragraph that contains the text present in a Knowledge article's Field |
The following is the default base CSS applied to each Knowledge article as it is rendered. Please note that the default color of normal text and links (anchor tags) are applied by the SDK to conform with the salesforce_contrast_primary and salesforce_brand_secondary color resource values, respectively.
* { color: $$salesforce_contrast_primary$$ } a { color: $$salesforce_brand_secondary$$ } body { padding: 1em; padding-top: 0.5em; } body * { width: auto !important; height: auto !important; max-width: 100%; } h1 { font-size: 137.5%; margin-bottom: 0; } p.modified_date { font-size: 62.5%; }
Public Methods | |||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|
abstract String |
getCssForArticle(ArticleSummary articleSummary)
Provide CSS content to be embedded in the head of a Knowledge article as it is being
loaded into a WebView.
|
Provide CSS content to be embedded in the head of a Knowledge article as it is being
loaded into a WebView. The ArticleSummary
of the article is given as an argument so it
can be identified and you may return CSS tailored for that article.
articleSummary | The ArticleSummary of the article being loaded |
---|