I am using Xamarin.Forms and having difficulty using FontAwesome.
This font has its specific code to use.
public const string InfoCircle = "\uf05a";
I need to use them in a listview menu.
If I use them directly by typing it in Label, it works fine, but if I bring the font value from an API for example, instead of the FontAwesome-converted icon, the font-specific code appears. How to make the font appear correctly?
Thanks.
Print of iOS Simulator
Related
I'm currently evaluating Xamarin Forms as an alternative to our webbased HTML applications targeting mobile platforms.
Our applications often use graphical symbols embedded in paragraphs of text.
The desired effect looks like this:
Of course the text also has to be able to freely wrap around, including all the symbols. In HTML this is simply achieved like this:
<p>Sample text with <img src="sample.jpg"> embedded</p>
How can I achieve the same effect using Xamarin Forms? I already looked at FormattedStrings which allow formatting of subparagraphs of Labels, however they do not seem to allow embedding of images.
Also please note that the solution is required to support iOS, Android and Windows Phone 8.1 at least.
Obviously being forced to use a WebView almost defeats the point of moving a HTML5 app to Xamarin!
In the Xamarin Forums a similar question has been asked: https://forums.xamarin.com/discussion/1649/text-with-image
To solve the problem Tomasz Cielecki cooked up some sample code here: https://gist.github.com/Cheesebaron/5034440
He then went onto blog about it here:
http://blog.ostebaronen.dk/2013/02/adding-images-to-textview-and-edittext.html
<snip>
I started out with a super simple sample trying to get an Image shown in a TextView. I googled up some solutions and sure, Spannables allow using ImageSpan inside of them! There were nice samples and such, and I came up with this.
ImageSpan in TextView
//Load up your drawable.
var imageSpan = new ImageSpan(this, Resource.Drawable.Icon);
//Set the text of SpannableString from TextView
var spannableString = new SpannableString(textView.Text);
//Add image at end of string
spannableString.SetSpan(imageSpan, textView.Text.Length-1, textView.Text.Length, 0);
Easy, huh? And you can add loads of other Spans to the Spannable, such as StyleSpan, which you can style your fonts with bold, italic and other styles.
Since that was so easy, I quickly tried to do that with an EditText. It also works just fine...
</snip>
Currently, the only way to have symbols and images within text blocks is to use WebView (https://developer.xamarin.com/guides/xamarin-forms/working-with/webview/)
var browser = new WebView();
var htmlSource = new HtmlWebViewSource ();
htmlSource.Html = #"<html><body>
<h1>Xamarin.Forms</h1>
<p>Welcome to WebView.</p>
</body></html>";
browser.Source = htmlSource;
I have been searching for a solution, but I couldn't succeed. The problem is as follows.
I have a WPF application where I am using FlowDocuments. I want to create a corresponding application on Android and share documents between those applications (WPF and Android) using a web service.
Android has SpannableString. But I couldn't figure out if we have a control in Android, like RichTextBox in WPF.
To sum up my question, Is there a format like Rich Text Format and an Android control to both display and manipulate this document on Android?
You can make use of the TextView together with the span fields to set different text styles (similar to Runs on XAML). There is also a SpannableStringBuilder which might ease this process.
SpannableString text = new SpannableString("Hello World!")
text.setSpan(new ForegroundColorSpan(Color.BLUE), 0, 5, 0);
text.setSpan(new StrikethroughSpan(), 7, 11, 0);
When I run my Windows Universal App on my Windows 8.1 phone, the LiveTile has additional text (the name of my app) on it that I'm trying to hide. The text seems to be coming from the Package.appxmanifest
<m3:VisualElements DisplayName="This Text Appears" ...
I found a similar question (Is it possible to create a Windows Phone live tile where no title is displayed?) that suggests leaving the value empty. When I do this, Visual Studio complains that it is invalid and I'm not able to compile. Removing the DisplayName entirely also results in an error.
I can see other applications that do not show any text, so it does seem possible.
Can anyone tell me how to hide the DisplayText from my LiveTile, but still have the name of my app appear correctly on the list of installed apps on the phone?
The template I'm using for the live tile (TileWide310x150Image).
The DisplayName attribute inside the Package.appxmanifest file is required and cannot be left blank. It's also the name that will show in the Phone's list of installed Apps. You want that be the proper name of your app.
The name of the app will appear on the LiveTile and, in that context, it's called 'Branding'.
https://msdn.microsoft.com/en-us/library/windows/apps/br212854.aspx
<binding template = tileTemplateNameV2
fallback? = tileTemplateNameV1
lang? = string
baseUri? = anyURI
branding? = "none" | "logo" | "name"
addImageQuery? = boolean
contentId? = string >
It seems to default to 'name', but by setting it to 'none' the text will no longer be displayed on the live tile.
I was able to remove the Wide Tile Display Name in a Windows Phone 8.1 Runtime C# Application with the following code:
XmlDocument squareTileXml = TileUpdateManager.GetTemplateContent(TileTemplateType.TileWide310x150PeekImage04);
XmlNodeList brandAttribute = squareTileXml.GetElementsByTagName("binding");
((XmlElement)brandAttribute[0]).SetAttribute("branding", "none");
squareTileXml is the name of the XML being configured to the Live Tile while TileWide310x150PeekImage04 is the chosen template.
Basically I specified a tile template (documentation) and I changed the property branding, which is inside the binding in the XML tree, according to this documentation, to none, removing the Display Name.
I'm not sure if this is the right way of configuring that, but at least it worked.
I have an asp.net website, in which I need to change the textbox font depending upon the language selected by the user.There are 2 radio buttons for 2 different languages English and Hindi.When the user selects one of these languages,the textbox font is changed through the following piece of code:
if(rbEnglish.Checked==true)
{
TextBox1.Font.Name="Times New Roman";
}
else if(rbHindi.Checked==true)
{
TextBox1.Font.Name="Shivaji05";
}
This works on the local computer but when the website is hosted,the Hindi font does not appear.What should be done to get this working?
Your question is strange; I think you made a simple mistake. Did you check your website with some developers tools like FireBug(in firefox), be sure that your text box gets your font style; there may be a css style in your host that overrides your internal style with somthing like "!important". Another possibility, Are you sure that you are visiting it on a client that has your Hindi font? Are you updating your text box with asp:UpdatePanel? does it work fine for other activities?
I am building a mobile site and the footer has an background.
I want to check if the browser supports css property, background-image, if true display background with specific html, else display a different set of html.
I am using the following :
HttpBrowserCapabilities bc = new HttpBrowserCapabilities();
I can't seem to get a check for backgrounds.
The reason why I want to check for BG-image support is coz I have to switch between 2 sets of html. 1 with html text and bg image, and the other with the text on the image - sliced for each word/link...to give the same effect.
to get information by HttpBrowserCapabilities, you have to use Request.Browser property.
HttpBrowserCapabilities browerCapabilities = Request.Browser;
I think Asp.net will automatically check the type of the browser and render the page accordingly. So if the the browser don't support background images it will not come.
Another idea to solve the issue is getting the browser type by using code, then you can show or hide the background images based on the type.