

{"id":1618,"date":"2022-03-17T09:00:31","date_gmt":"2022-03-17T00:00:31","guid":{"rendered":"https:\/\/curecode.jp\/tech\/?p=1618"},"modified":"2022-03-14T00:23:33","modified_gmt":"2022-03-13T15:23:33","slug":"xamarin-android-materialcomponents-textinputedittext-create-dynamically","status":"publish","type":"post","link":"https:\/\/curecode.jp\/tech\/xamarin-android-materialcomponents-textinputedittext-create-dynamically\/","title":{"rendered":"[Xamarin] Android MaterialComponents \u306e TextInputEditText \u3092\u52d5\u7684\u306b\u751f\u6210\u3059\u308b"},"content":{"rendered":"<p>\n  <a href=\"https:\/\/curecode.jp\/tech\/android-materialcomponents-textinputedittext-style-inflateexception\/\" title=\"Android MaterialComponents \u306e TextInputEditText \u306e style \u3092\u6307\u5b9a\u3059\u308b\u3068 InflateException \u304c\u767a\u751f\u3059\u308b\">Android MaterialComponents \u306e TextInputEditText \u3092\u4f7f\u3046\u6642\u306e\u6ce8\u610f\u70b9<\/a>\u3067\u306f\u9759\u7684\u306b\u751f\u6210\u3059\u308b\u65b9\u6cd5\u3092\u66f8\u304d\u307e\u3057\u305f\u3002\n<\/p>\n<p>\n  \u4eca\u56de\u306f Xamarin.Android \u3067\u52d5\u7684\u306b\u751f\u6210\u3059\u308b\u65b9\u6cd5\u3067\u3059\u3002Xamarin \u306a\u306e\u3067 C# \u3067\u3059\u3002\n<\/p>\n<h3>\u57fa\u672c\u7684\u306a\u8003\u3048\u65b9<\/h3>\n<p>\n  \u9759\u7684\u306a\u65b9\u6cd5\u3067 XML \u306b\u66f8\u304f\u306e\u3068\u540c\u69d8\u306b\u3001TextInputLayout \u3092\u751f\u6210\u3057\u3001\u305d\u306e\u4e2d\u306b TextInputEditText \u3092\u914d\u7f6e\u3057\u307e\u3059\u3002\n<\/p>\n<pre><code class=\"cs\">\r\n    var textInputLayout = new TextInputLayout(context); \r\n\r\n    var edit = new TextInputEditText(context);\r\n    edit.InputType = Android.Text.InputTypes.ClassText;\r\n    edit.Text = \"\u30c6\u30ad\u30b9\u30c8\";\r\n    \r\n    textInputLayout.AddView(edit);\r\n<\/code><\/pre>\n<p>\n  \u3053\u3053\u307e\u3067\u3067\u30de\u30c6\u30ea\u30a2\u30eb\u30c7\u30b6\u30a4\u30f3\u306e\u901a\u5e38\u306e\u30c6\u30ad\u30b9\u30c8\u30a8\u30c7\u30a3\u30c3\u30c8\u306f\u8868\u793a\u3067\u304d\u307e\u3059\u3002\n<\/p>\n<h3>\u30b9\u30bf\u30a4\u30eb\u3092\u4f7f\u7528\u3059\u308b\u5834\u5408<\/h3>\n<p>\n  \u9759\u7684\u306a\u65b9\u6cd5\u3067\u3082\u8ff0\u3079\u307e\u3057\u305f\u304c TextInputEditText \u306b\u306f 3\u3064\u306e\u30b9\u30bf\u30a4\u30eb\u304c\u3042\u308a\u307e\u3059\u3002\n<\/p>\n<figure>\n<img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/curecode.jp\/tech\/wp-content\/uploads\/2022\/03\/TextInputLayout-300x151.png\" alt=\"TextInputLayout \u306e\u7a2e\u985e\" width=\"300\" height=\"151\" class=\"aligncenter size-medium wp-image-1616\" srcset=\"https:\/\/curecode.jp\/tech\/wp-content\/uploads\/2022\/03\/TextInputLayout-300x151.png 300w, https:\/\/curecode.jp\/tech\/wp-content\/uploads\/2022\/03\/TextInputLayout-768x387.png 768w, https:\/\/curecode.jp\/tech\/wp-content\/uploads\/2022\/03\/TextInputLayout-200x101.png 200w, https:\/\/curecode.jp\/tech\/wp-content\/uploads\/2022\/03\/TextInputLayout.png 920w\" sizes=\"auto, (max-width: 300px) 100vw, 300px\" \/><br \/>\n<\/figure>\n<p>\n  \u52d5\u7684\u306b\u751f\u6210\u3059\u308b\u5834\u5408\u3001\u30b3\u30fc\u30c9\u306f\u3069\u3046\u3059\u308c\u3070\u3088\u3044\u3067\u3057\u3087\u3046\u304b\u3002\n<\/p>\n<p>\n  \u307e\u305a\u306f ContextThemeWrapper \u3092\u4f7f\u7528\u3057\u307e\u3059\u3002ContextThemeWrapper \u3068\u306f\u3042\u308b Context \u306e Theme \u3092\u4e0a\u66f8\u304d\u3057\u305f Context \u3092\u65b0\u3057\u4f5c\u6210\u3059\u308b\u3053\u3068\u304c\u3067\u304d\u308b\u3082\u306e\u3067\u3059\u3002\u3053\u308c\u3067\u30c6\u30fc\u30de\u3092\u6761\u4ef6\u306b\u3088\u3063\u3066\u7f6e\u304d\u63db\u3048\u305f\u308a\u3059\u308b\u3053\u3068\u304c\u3067\u304d\u307e\u3059\u3002\n<\/p>\n<pre><code class=\"cs\">\r\n    \/\/ OutlinedBox\u30c6\u30fc\u30de\u3092\u9069\u7528\u3057\u305f contextWrapper \u3092\u4f5c\u6210\r\n    var contextWrapper = new ContextThemeWrapper(context, Resource.Style.Widget_MaterialComponents_TextInputLayout_OutlinedBox);\r\n    \/\/ TextInputEditText \u3092\u8f09\u305b\u308b TextInputLayout \u3092\u751f\u6210\u3059\u308b\r\n    var textInputLayout = new TextInputLayout(contextWrapper);\r\n\r\n    var edit = new TextInputEditText(context);\r\n    edit.InputType = Android.Text.InputTypes.ClassText;\r\n    edit.Text = \"\u30c6\u30ad\u30b9\u30c8\";\r\n    \r\n    textInputLayout.AddView(edit);\r\n<\/code><\/pre>\n<p>\n  \u3068\u3053\u308d\u304c\u3001\u3053\u308c\u3060\u3051\u3060\u3068 Default \u306e\u30c6\u30fc\u30de\u304c MaterialComponents \u306e FilledBox \u306b\u306f\u306a\u308a\u307e\u3059\u304c\u3001OutlinedBox \u306b\u306f\u306a\u308a\u307e\u305b\u3093\u3002\u4f55\u304c\u8db3\u308a\u306a\u3044\u306e\u3067\u3057\u3087\u3046\u304b\u3002\n<\/p>\n<h3>BoxBackgroundMode \u3092\u8a2d\u5b9a<\/h><\/p>\n<p>\n  \u7d50\u8ad6\u304b\u3089\u8a00\u3046\u3068 TextInputLayout.BoxBackgroundMode \u3092\u8a2d\u5b9a\u3059\u308b\u5fc5\u8981\u304c\u3042\u308a\u307e\u3059\u3002\n<\/p>\n<pre><code class=\"cs\">\r\n    \/\/ OutlinedBox\u30c6\u30fc\u30de\u3092\u9069\u7528\u3057\u305f contextWrapper \u3092\u4f5c\u6210\r\n    var contextWrapper = new ContextThemeWrapper(context, Resource.Style.Widget_MaterialComponents_TextInputLayout_OutlinedBox);\r\n    \/\/ TextInputEditText \u3092\u8f09\u305b\u308b TextInputLayout \u3092\u751f\u6210\u3059\u308b\r\n    var textInputLayout = new TextInputLayout(contextWrapper);\r\n\r\n    \/\/ Outline \u30e2\u30fc\u30c9\u306b\u3059\u308b\u306b\u306f BoxBackgroundMode \u306e\u8a2d\u5b9a\u3082\u5fc5\u8981\r\n    textInputLayout.BoxBackgroundMode = TextInputLayout.BoxBackgroundOutline;\r\n    \/\/ \u89d2\u4e38\u3092\u8a2d\u5b9a\r\n    textInputLayout.SetBoxCornerRadii(10, 10, 10, 10);\r\n\r\n    var edit = new TextInputEditText(context);\r\n    edit.InputType = Android.Text.InputTypes.ClassText;\r\n    edit.Text = \"\u30c6\u30ad\u30b9\u30c8\";\r\n    \r\n    textInputLayout.AddView(edit);\r\n<\/code><\/pre>\n<h3>\u53c2\u8003\u30b5\u30a4\u30c8<\/h3>\n<ul class=\"links\">\n<li><a href=\"https:\/\/stackoverflow.com\/questions\/67734746\/outlinedbox-of-textinputlayout-is-not-showing-programmatically\">OutlinedBox of TextInputLayout is not showing programmatically<\/a><\/li>\n<\/ul>\n<h3>IT\u30a8\u30f3\u30b8\u30cb\u30a2\u52df\u96c6\u4e2d\uff01<\/h3>\n<p>\u30ad\u30e5\u30a2\u30b3\u30fc\u30c9\u682a\u5f0f\u4f1a\u793e\u306fIT\u30a8\u30f3\u30b8\u30cb\u30a2\u3092\u52df\u96c6\u3057\u3066\u304a\u308a\u307e\u3059\u3002\u5c11\u4eba\u6570\u306e\u8077\u5834\u306a\u306e\u3067\u3001\u4e0a\u6d41\u30fb\u4e0b\u6d41\u3084\u30b5\u30fc\u30d0\u30fc\u30fb\u30af\u30e9\u30a4\u30a2\u30f3\u30c8\u5bfe\u5fdc\u306e\u57a3\u6839\u306a\u304f\u3001\u3042\u306a\u305f\u306e\u5f37\u307f\u3092\u6d3b\u304b\u3057\u306a\u304c\u3089 \u3044\u308d\u3044\u308d\u306a\u3053\u3068\u306b\u30c1\u30e3\u30ec\u30f3\u30b8\u53ef\u80fd\u3067\u3059\u3002\u30a8\u30f3\u30b8\u30cb\u30a2\u3068\u3057\u3066\u306e\u672a\u7d4c\u9a13\u306e\u65b9\u3001\u7d4c\u9a13\u304c\u5c11\u306a\u3044\u65b9\u3082\u6b53\u8fce\u3057\u3066\u3044\u307e\u3059\u3002<\/p>\n<p>\u4e0b\u8a18\u3088\u308aIT\u30a8\u30f3\u30b8\u30cb\u30a2\u52df\u96c6\u306e\u63a1\u7528\u60c5\u5831\u3092\u3054\u89a7\u3044\u305f\u3060\u3051\u307e\u3059\u3002<\/p>\n<div class=\"curecode_recruit_bn\">\n\t\t\t\t<a href=\"https:\/\/curecode.jp\/recruit\/itengineer\/\" target=\"_blank\" rel=\"noopener noreferrer\"><br \/>\n\t\t\t\t\t\t<img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/curecode.jp\/tech\/wp-content\/themes\/tech\/images\/it_recruit.png?20241220\" alt=\"\u4e8b\u696d\u62e1\u5927\u306b\u4f34\u3044\u65b0\u3057\u3044\u9818\u57df\u306b\u4e00\u7dd2\u306b\u53d6\u308a\u7d44\u3093\u3067\u3044\u304f\u30e1\u30f3\u30d0\u30fc\u3092\u52df\u96c6\u3057\u307e\u3059\u3002\"  width=\"500\" height=\"180\"\/><br \/>\n\t\t\t\t<\/a>\n\t\t<\/div>\n<h3>\u30ad\u30e5\u30a2\u30b3\u30fc\u30c9\u516c\u5f0f\u30a4\u30f3\u30b9\u30bf\u30b0\u30e9\u30e0<\/h3>\n<p>\u30ad\u30e5\u30a2\u30b3\u30fc\u30c9\u682a\u5f0f\u4f1a\u793e\u306e\u65b0\u30b5\u30fc\u30d3\u30b9\u60c5\u5831\u3084\u3001\u30aa\u30d5\u30a3\u30b9\u30e9\u30a4\u30d5\u306e\u7d20\u6575\u306a\u77ac\u9593\u307e\u3067\u3002\u79c1\u305f\u3061\u306e\u65e5\u3005\u306e\u55b6\u307f\u3092\u3054\u7d39\u4ecb\u3057\u307e\u3059\u3002<\/p>\n<div class=\"curecode_recruit_bn\">\n\t\t\t\t<a href=\"https:\/\/www.instagram.com\/curecode\/\" target=\"_blank\" rel=\"noopener noreferrer\"><br \/>\n\t\t\t\t\t\t<img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/curecode.jp\/tech\/wp-content\/themes\/tech\/images\/insta_bn.png?20241220\" alt=\"\u4e8b\u696d\u62e1\u5927\u306b\u4f34\u3044\u65b0\u3057\u3044\u9818\u57df\u306b\u4e00\u7dd2\u306b\u53d6\u308a\u7d44\u3093\u3067\u3044\u304f\u30e1\u30f3\u30d0\u30fc\u3092\u52df\u96c6\u3057\u307e\u3059\u3002\"  width=\"500\" height=\"180\"\/><br \/>\n\t\t\t\t<\/a>\n\t\t<\/div>\n","protected":false},"excerpt":{"rendered":"<p>Android MaterialComponents \u306e TextInputEditText \u3092\u4f7f\u3046 [&hellip;]<\/p>\n","protected":false},"author":8,"featured_media":1440,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[127,141],"tags":[19,184,148],"class_list":["post-1618","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-android","category-xamarin","tag-android","tag-materialcompoments","tag-xamarin"],"_links":{"self":[{"href":"https:\/\/curecode.jp\/tech\/wp-json\/wp\/v2\/posts\/1618","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/curecode.jp\/tech\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/curecode.jp\/tech\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/curecode.jp\/tech\/wp-json\/wp\/v2\/users\/8"}],"replies":[{"embeddable":true,"href":"https:\/\/curecode.jp\/tech\/wp-json\/wp\/v2\/comments?post=1618"}],"version-history":[{"count":2,"href":"https:\/\/curecode.jp\/tech\/wp-json\/wp\/v2\/posts\/1618\/revisions"}],"predecessor-version":[{"id":1620,"href":"https:\/\/curecode.jp\/tech\/wp-json\/wp\/v2\/posts\/1618\/revisions\/1620"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/curecode.jp\/tech\/wp-json\/wp\/v2\/media\/1440"}],"wp:attachment":[{"href":"https:\/\/curecode.jp\/tech\/wp-json\/wp\/v2\/media?parent=1618"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/curecode.jp\/tech\/wp-json\/wp\/v2\/categories?post=1618"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/curecode.jp\/tech\/wp-json\/wp\/v2\/tags?post=1618"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}