AutoFit Button.Text FontSize

Hi, 

Is there a way to AutoFit the text inside SfButton control given a certain Width and Height? I believe this behavior should be supported.

As an example, see Forms9Patch https://baskren.github.io/Forms9Patch/guides/Buttons.html, whose text can be set to AutoFit.

Cheers,
Miguel

7 Replies 1 reply marked as answer

SJ Suyamburaja Jayakumar Syncfusion Team November 24, 2020 01:09 PM UTC

Hi Miguel,  
   
Greetings from Syncfusion.  
  
We would like to let you know that by default SfButton has AutoSizeFit support, as per the changes of text update, it adjusts its size.  For your reference, 
 
XAML: 
<StackLayout>  
        <buttons:SfButton x:Name="button"  Text="{Binding Source="{x:Reference Name=entry}" , Path=Text}" HorizontalOptions="Center" VerticalOptions="Center" />  
        <Entry x:Name="entry" Margin="10,10,0,0" WidthRequest="110" />  
    </StackLayout>  
 
 
Please let us know if you need any further assistance. 
 
Regards, 
Suyamburaja J. 



MR Miguel Rubio November 24, 2020 01:30 PM UTC

Hi Suyamburaja J.,

What you attached works until you restrict the width of StackLayout.

XAML: 
<StackLayout WidthRequest="200" HorizontalOptions = "Center">  
        <buttons:SfButton x:Name="button"  Text="{Binding Source="{x:Reference Name=entry}" , Path=Text}" HorizontalOptions="Center" VerticalOptions="Center" />  
        <Entry x:Name="entry" Margin="10,10,0,0" WidthRequest="110" />  
    </StackLayout>  



What I am looking for is, given certain Width and Height, adjust the FontSize of the Text so it fits the size of the SfButton.


SJ Suyamburaja Jayakumar Syncfusion Team November 26, 2020 03:03 AM UTC

Hi Miguel,  
  
We have validated your case with having the specified width to SFButton hold parent layout and updated the text dynamically it will not autofit to its size. SfButton has implemented based of framework control like Grid as parent and added the Label to display the Text of SfButton. Hence, we have also ensured this with Label and itself working fine. Hence, we need a some more time to validate this further and provide any sample level or possible fix on or before November 27, 2020.  
  
Note: We ensured it by updating the text dynamically. Whether your requirement is similar that of provided link in your first update to make the AutoFit based on the bounds and Width. Please share this also. 
 
Regards, 
Suyamburaja J. 



MR Miguel Rubio November 26, 2020 08:13 AM UTC

Hi,

The use of  ```TextView.SetAutoSizeTextTypeUniformWithConfiguration(...) ``` for Android TextView and ``` Control.AdjustFontSizeToFitWidth ``` for iOS UILabel would make this work.

I tried to create my own renderer out of SfButtonRenderer but I am not sure how to access from there to it's TextView or UILabel.


SJ Suyamburaja Jayakumar Syncfusion Team November 29, 2020 04:56 PM UTC

Hi Miguel, 
 
We need some more time to validate this, since we have some technical block. Hence, we will update the complete details on or before November 30,2020. 
 
Limitation:  We failed to get the native control on custom renderer since control implementation from Syncfusion Border, all other customization happens through drawing. 
 
Regards,  
Suyamburaja J. 



SJ Suyamburaja Jayakumar Syncfusion Team November 30, 2020 12:29 PM UTC

Hi Miguel,  
   
Thanks for your patience. We tried to achieve through the workaround solution, but unable to achieve through the sample level. Hence, we have validated this for finding the feasibility of this feature with SfButton and we will update the complete status on tomorrow (December 1, 2020).  
   
Regards,   
Suyamburaja J. 



SJ Suyamburaja Jayakumar Syncfusion Team December 2, 2020 02:00 PM UTC

Hi Miguel,  
 
On further analysis of this feasibility, we have considered this as a feature request of SfButton and please find the feedback link below to track the status of this feature implementation,  
   
   
Please cast your vote to make it count. We will prioritize the features every release based on the demands and we do not have an immediate plan to implement this feature since we committed to already planned work. So, this feature will be available in any of our upcoming releases.  
    
If you have any more specification/suggestions to the feature request, you can add it as a comment in the portal. 
 
Regards, 
Suyamburaja J. 


Marked as answer
Loader.
Up arrow icon