How to alter text of label based on if the text would overflowing - in Xamarin forms - xamarin

I have a UI requirement for displaying the user name list like the ones that appear on social media posts for displaying people who liked the post.
The problem in it is the overflow thing.
if it's a single user. Simply display them.
If it's a long list and overflows the label length then out the overflowing user names has to removed and replaced with remaining user count text.
Since I search through web and found no Xamarin Forms way of doing this. I am thinking of creating a custom renderer for this and using native text measuring API to figure the text to be displayed.
Android
var textSize = paint.MeasureText(this.Control.Text);
iOS
NSAttributedString nS = new NSAttributedString(txt, font: this.Control.Font);
var textSize = nS.Size;
Am I in right path? Is there any other way of doing this?

Related

How to change the picker items font size in Xamarin IOS?

In Xamarin forms, for IOS if the picker item has lengthy text, that text is getting truncated. How to change the xamarin ios picker items font size using customrenderer or how to make the text fit without getting truncated?.
There is another alternative solution as well where you can change the alignment of Picker Item(Default is Center). You can make it left.
For adjusting Text and Style there are plenty of renderer solutions on Stack Overlfow.
For your ref, attaching one of those solutions.
Solution.

How to give width to the TabViewItem in Nativescript?

I want to implement sometthing like above where the camera tab has the smaller width compare to the others tab in TabView.
I did three tabs with same size but I don't know how to add one more tab but with smaller width.
You will have to update the width of native view that contains the camera within the tab layout. The code below lets the layout take only the width it requires to show the content within.
const view = nativeTabView.getChildAt(i),
layoutParams = view.getLayoutParams();
layoutParams.weight = 0;
layoutParams.width = android.widget.LinearLayout.LayoutParams.WRAP_CONTENT;
view.setLayoutParams(layoutParams);
Playground Sample
The above example is written in NativeScript Core / TypeScript, there is nothing you have to specifically if you are implementing this on Vue / Angular, just use the appropriate event binding syntax, you should be good.

How to change the size (resolution) of one pageview in Spotfire

I saw a viz in the company's repository, and I wish to replicate one of the feature.
The viz is consist of several pages with an introductory page. The introductory page contained a lot of information with a scrollable canvas, while other detail page had a fixed-to-window way of presenting data, showing each segment in one screen without the overall scroll bar.
What I want to know is how to only make one or part of the pages in the dxp file able to enable the scroll bar (larger canvas height), while the rest having the fit-to screen way of displaying the viz. Any approach will be appreciated.
PS:
The Document Property→General→Visualization area size→Custom size method changes the canvas size of all visualization table. Which is not able to fulfill this feature, as this property changes the canvas size of all pages in the dxp file, which is not what I expected.
sounds like they used a Text Area but it's hard to tell without seeing the document.
you can insert a Text Area the same way you do a visualization (via the toolbar or the main menu). you can then right click the Text Area to edit it either with the WYSIWYG editor or in raw HTML. Text Areas will show scrollbars to match the length of your content.

Today Extension: how to display long text?

I don't know whether I'm doing something wrong or if it's not possible: I'd like to display a longer text, but the height seems to be limited to 568 pixels (Maximum height of iOS 8 Today Extension?). I'm using a UITextView, so I would expect it to scroll, but that's not possible either.
Isn't there any way to display the full text?
Displaying such large text on a Notification Center widget, especially in iPhone 4S, 5 or 6, where space is limited, is a bad idea.
Instead, show a preview of the text, indicate that there is more text, and add a button to open the full app to read the rest of it.

How is/can the WP7 Office Hub panorama header markup be created?

WP7 Office hub panorama header looks like this:
What is it?
one solid image
two images (one for logo, one for "microsoft Office")
all vector elements
The answer interests me only because I know how to achieve this only in the first two cases.
Basically I need to create a TextBlock in PanoramaHeaderTemplate, that would be like this:
<TextBlock Foreground="Black"><Run Text="smallBold" FontWeight="Bold"/><Run Text="Normal"></TextBlock>
So the resulting panorama should have a look:
If I use FontWeight directive in the PanoramaHeaderTemplate - it for some reason has no effect.
If I use PanoramaTitleTemplate, I get the controllable text weight, but I have a panorama header element appear for some reason, that only displays a x:Key element name of the PanoramaItem, that results in an appearance of a header I don't need at all. This happens even if I don't define the panorama header.
So which is the correct way to achieve the look on the Panorama "upper element", whether it is Title or Header, that is shown on the smallBold.Normal figure?
I don't know what Office uses but it's irrelevant because, as a native app, it wasn't created with Silverlight.
You can create the same effect by changing the Panorama.TitleTemplate to contain whatever you want (TextBlocks, images, etc.). You may also have to adjust the defautl Style applied to the template to set a Height and Width for the PanningTitleLayer.
It's an image, straight across the panorama. It's very simple, as the panorama view was set up to display long images to support a better scrolling feel for the user.
So i would look into using images, as it's easier to achieve, what you are trying to do, with images, rather than a background image.
Some useful related questions/articles:
May Help, StackOverflow
UI Concepts For Windows Phone 7
How I made the ‘myChannel9' wp7 app
Capturing Windows Phone 7 Panorama Images

Resources