{"id":374,"date":"2017-11-03T15:44:44","date_gmt":"2017-11-03T15:44:44","guid":{"rendered":"http:\/\/sezeromer.com\/?p=374"},"modified":"2023-01-15T22:34:07","modified_gmt":"2023-01-15T19:34:07","slug":"xamarin-yuvarlak-entry","status":"publish","type":"post","link":"https:\/\/sezeromer.com\/en\/xamarin-yuvarlak-entry\/","title":{"rendered":"Xamarin Rounded Entry"},"content":{"rendered":"<p>One of the most challenging issues when working with cross-platfrom in <strong>Xamarin<\/strong> is design. For example, when we check an entry, we can not say that the project has a lot of appeal when we look at the design. We must write <strong>Custom Renderer<\/strong> for each platform by taking advantage of the script we wrote earlier in our project.<\/p>\n<p>If I want my entities to look like it, I have to give them a shape. I&#8217;ll do this on the Android side as an example. In the Drawable folder under the Resources folder under the project section, we create an xml file that will determine how our entry will look. I gave this file the name RoundedEntry. After creating the file, we need to write some code. We determine which color will be used for solid and entrynin. With Stroke, we choose which color the roundness of the entry just outside will be. With the Cornes feature we determine how to look in 4 directions. If you need something like this, you can change it according to it.<\/p>\n<div class=\"wp-block-codemirror-blocks code-block \">\n<pre class=\"CodeMirror\" data-setting=\"{&quot;mode&quot;:&quot;swift&quot;,&quot;mime&quot;:&quot;text\/x-swift&quot;,&quot;theme&quot;:&quot;default&quot;,&quot;lineNumbers&quot;:true,&quot;lineWrapping&quot;:false,&quot;styleActiveLine&quot;:true,&quot;readOnly&quot;:true,&quot;align&quot;:&quot;&quot;}\">&lt;?xml version=\"1.0\" encoding=\"utf-8\" ?&gt;\r\n&lt;shape xmlns:android=\"http:\/\/schemas.android.com\/apk\/res\/android\"\r\nandroid:shape=\"rectangle\" android:padding=\"10dp\" &gt;  \r\n  &lt;solid android:color=\"#FFFFFF\"\/&gt;\r\n  &lt;stroke android:width=\"2dp\" android:color=\"#00FF00\" \/&gt;\r\n  &lt;corners\r\n   android:bottomRightRadius=\"15dp\"\r\n   android:bottomLeftRadius=\"15dp\"\r\n   android:topLeftRadius=\"15dp\"\r\n   android:topRightRadius=\"15dp\"\/&gt;\r\n&lt;\/shape&gt;<\/pre>\n<\/div>\n<p>After we have done the xml part we are coming to write a <strong>Custom Renderer<\/strong> on the <strong>Android<\/strong> part. Again, I&#8217;m opening the <strong>Custom Renderers<\/strong> folder under the <strong>Android<\/strong> platform and opening a class called <strong>CustomRoundedEntryRenderer<\/strong> to quickly find what my files look like and search for them right away. This class is the class that will enable us to see the entrances we create in this class when we use entrances that are the defaults in our project. We first set this class to inherit from the EntryRenderer, and then override the <strong>OnElementChanged<\/strong> function. After we have done these, we check to see if we have our control. If there is an entry, we call this control the form we created in the RoundedEntry file under the <strong>Drawable<\/strong> folder under our Resource folder. We also write the phrase that this page is a Custom Renderer, which is a must for Custom Renderer.<\/p>\n<div class=\"wp-block-codemirror-blocks code-block \">\n<pre class=\"CodeMirror\" data-setting=\"{&quot;mode&quot;:&quot;swift&quot;,&quot;mime&quot;:&quot;text\/x-swift&quot;,&quot;theme&quot;:&quot;default&quot;,&quot;lineNumbers&quot;:true,&quot;lineWrapping&quot;:false,&quot;styleActiveLine&quot;:true,&quot;readOnly&quot;:true,&quot;align&quot;:&quot;&quot;}\">[assembly: ExportRenderer(typeof(RoundedEntry.CustomRenderers.RoundedEntry),\r\ntypeof(CustomRoundedEntryRenderer))]\r\nnamespace RoundedEntry.Droid.CustomRenderers\r\n{\r\n    public class CustomRoundedEntryRenderer: EntryRenderer\r\n    {\r\n        protected override void OnElementChanged(ElementChangedEventArgs&lt;Entry&gt; e)\r\n        {\r\n            base.OnElementChanged(e);\r\n            if (Control!=null)\r\n            {\r\n                Control.Background = this.Resources.GetDrawable(Resource.Drawable.RoundedEntry);\r\n            }\r\n        }\r\n    }\r\n}<\/pre>\n<\/div>\n<p>Of course I do not want all my entities to be the same, so I set up a class in the portable layer and set this class to inherit from the entry control. I actually mentioned this in <strong>Custom Renderer<\/strong>. Actually, that&#8217;s all we do. Very easy and simple operations. Finally we need to show it on a page that this is our new control. You can do this on the <strong>xaml<\/strong> side as you can on the cs side. Cs on the side is very simple to do but you need to add a line of code to do it on the xaml side. Since we can use a variable called Rounded Entry, we need to add xmlns: RoundedEntry = &#8220;clr-namespace: RoundedEntry.CustomRenderers&#8221;.<\/p>\n<div class=\"wp-block-codemirror-blocks code-block \">\n<pre class=\"CodeMirror\" data-setting=\"{&quot;mode&quot;:&quot;swift&quot;,&quot;mime&quot;:&quot;text\/x-swift&quot;,&quot;theme&quot;:&quot;default&quot;,&quot;lineNumbers&quot;:true,&quot;lineWrapping&quot;:false,&quot;styleActiveLine&quot;:true,&quot;readOnly&quot;:true,&quot;align&quot;:&quot;&quot;}\">&lt;?xml version=\"1.0\" encoding=\"utf-8\" ?&gt;\r\n&lt;ContentPage xmlns=\"http:\/\/xamarin.com\/schemas\/2014\/forms\"\r\n             xmlns:x=\"http:\/\/schemas.microsoft.com\/winfx\/2009\/xaml\"\r\n             xmlns:RoundedEntry=\"clr-namespace:RoundedEntry.CustomRenderers\"\r\n             x:Class=\"RoundedEntry.Views.AnaSayfa\"&gt;\r\n    &lt;ContentPage.Content&gt;\r\n        &lt;StackLayout Padding=\"40\"&gt;\r\n            &lt;RoundedEntry:RoundedEntry\r\n                Placeholder=\"Ad\u0131n\u0131z\u0131 Giriniz\"\/&gt;\r\n        &lt;\/StackLayout&gt;\r\n    &lt;\/ContentPage.Content&gt;\r\n&lt;\/ContentPage&gt;<\/pre>\n<\/div>\n<p><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter size-full wp-image-377\" src=\"http:\/\/sezeromer.com\/wp-content\/uploads\/2017\/11\/Xamarin-Rounded-Entry-e1509724348923.jpg\" alt=\"\" width=\"432\" height=\"302\" srcset=\"https:\/\/sezeromer.com\/wp-content\/uploads\/2017\/11\/Xamarin-Rounded-Entry-e1509724348923.jpg 432w, https:\/\/sezeromer.com\/wp-content\/uploads\/2017\/11\/Xamarin-Rounded-Entry-e1509724348923-300x210.jpg 300w\" sizes=\"(max-width: 432px) 100vw, 432px\" \/><\/p>\n<p>If you want to study the project you can reach <a href=\"https:\/\/github.com\/omersezer\/XamarinRoundedEntry\">here<\/a>.<\/p>","protected":false},"excerpt":{"rendered":"<p>One of the most challenging issues when working with cross-platfrom in Xamarin is design. For example, when we check an entry, we can not say that the project has a lot of appeal when we look at the design. We must write Custom Renderer for each platform by taking advantage of the script we wrote [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":377,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[289,3],"tags":[167,7,169,22,119,170,168],"class_list":["post-374","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-android","category-xamarin-ile-yapilmis-projeler","tag-cross-plartform","tag-omer-sezer","tag-rounded-entry","tag-xamarin","tag-xamarin-forms","tag-xaml","tag-yuvarlak-entry"],"aioseo_notices":[],"_links":{"self":[{"href":"https:\/\/sezeromer.com\/en\/wp-json\/wp\/v2\/posts\/374"}],"collection":[{"href":"https:\/\/sezeromer.com\/en\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/sezeromer.com\/en\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/sezeromer.com\/en\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/sezeromer.com\/en\/wp-json\/wp\/v2\/comments?post=374"}],"version-history":[{"count":7,"href":"https:\/\/sezeromer.com\/en\/wp-json\/wp\/v2\/posts\/374\/revisions"}],"predecessor-version":[{"id":2559,"href":"https:\/\/sezeromer.com\/en\/wp-json\/wp\/v2\/posts\/374\/revisions\/2559"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/sezeromer.com\/en\/wp-json\/wp\/v2\/media\/377"}],"wp:attachment":[{"href":"https:\/\/sezeromer.com\/en\/wp-json\/wp\/v2\/media?parent=374"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/sezeromer.com\/en\/wp-json\/wp\/v2\/categories?post=374"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/sezeromer.com\/en\/wp-json\/wp\/v2\/tags?post=374"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}