{"id":127,"date":"2023-02-18T11:53:51","date_gmt":"2023-02-18T03:53:51","guid":{"rendered":"https:\/\/www.appblog.cn\/?p=127"},"modified":"2023-02-18T11:54:32","modified_gmt":"2023-02-18T03:54:32","slug":"android-edittext-cursor","status":"publish","type":"post","link":"https:\/\/www.appblog.cn\/index.php\/2023\/02\/18\/android-edittext-cursor\/","title":{"rendered":"Android\u8bbe\u7f6eEditText\u5149\u6807\u4f4d\u7f6e\u3001\u7c97\u7ec6\u989c\u8272"},"content":{"rendered":"<h2>\u5149\u6807\u4f4d\u7f6e<\/h2>\n<ul>\n<li>\u5982\u679c\u8bbe\u7f6e\u7684\u662f\u8d77\u59cb\u4f4d\u7f6e\uff0c\u53ea\u9700\u8981\u5728xml\u6587\u4ef6\u4e2d\u52a0\u4e0a<\/li>\n<\/ul>\n<pre><code class=\"language-xml\">android:gravity=&quot;right&quot;<\/code><\/pre>\n<p>\u5373\u53ef\u8ba9\u5149\u6807\u9ed8\u8ba4\u5728\u6700\u53f3\u4fa7\u95ea\u70c1\u3002<\/p>\n<p><!-- more --><\/p>\n<ul>\n<li>\u5982\u679c\u8bbe\u7f6e\u6307\u5b9a\u7684\u4f4d\u7f6e\uff0c\u9700\u8981\u5728\u4ee3\u7801\u4e2d<\/li>\n<\/ul>\n<pre><code class=\"language-java\">EditText et = (EditText) findViewById(R.id.editText);\net.setSelection(et.getText().toString().length());<\/code><\/pre>\n<p>\u6307\u5b9a\u5373\u53ef\u3002length\u662f\u5728\u6587\u5b57\u6700\u540e\u7aef\u95ea\u70c1\u3002<\/p>\n<h2>\u7c97\u7ec6\u989c\u8272<\/h2>\n<p>\u8bbe\u7f6e\u5149\u6807\u989c\u8272\u548c\u7c97\u7ec6\u3002\u9700\u8981\u5728drawable\u76ee\u5f55\u4e0b\u65b0\u5efa\u7684shape.xml\u6587\u4ef6\u4e2d<\/p>\n<pre><code class=\"language-xml\">&lt;shape xmlns:android=&quot;http:\/\/schemas.android.com\/apk\/res\/android&quot; android:shape=&quot;rectangle&quot;&gt;\n    &lt;size android:width=&quot;1dp&quot; \/&gt;\n    &lt;solid android:color=&quot;#008000&quot; \/&gt;\n&lt;\/shape&gt;<\/code><\/pre>\n<p>\u5728EditText\u8bbe\u7f6e<\/p>\n<pre><code class=\"language-xml\">android:textCursorDrawable=&quot;@drawable\/shape&quot;<\/code><\/pre>\n<p>\u5982\u679c\u8bbe\u7f6e<\/p>\n<pre><code class=\"language-xml\">android:textCursorDrawable=&quot;@null&quot;<\/code><\/pre>\n<p>\u5219\u9ed8\u8ba4\u8ddftextColor\u989c\u8272\u4e00\u6837<\/p>\n","protected":false},"excerpt":{"rendered":"<p>\u5149\u6807\u4f4d\u7f6e \u5982\u679c\u8bbe\u7f6e\u7684\u662f\u8d77\u59cb\u4f4d\u7f6e\uff0c\u53ea\u9700\u8981\u5728xml\u6587\u4ef6\u4e2d\u52a0\u4e0a android:gravity=&quot;righ [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[61],"tags":[],"class_list":["post-127","post","type-post","status-publish","format-standard","hentry","category-android-basic"],"_links":{"self":[{"href":"https:\/\/www.appblog.cn\/index.php\/wp-json\/wp\/v2\/posts\/127","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.appblog.cn\/index.php\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.appblog.cn\/index.php\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.appblog.cn\/index.php\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.appblog.cn\/index.php\/wp-json\/wp\/v2\/comments?post=127"}],"version-history":[{"count":0,"href":"https:\/\/www.appblog.cn\/index.php\/wp-json\/wp\/v2\/posts\/127\/revisions"}],"wp:attachment":[{"href":"https:\/\/www.appblog.cn\/index.php\/wp-json\/wp\/v2\/media?parent=127"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.appblog.cn\/index.php\/wp-json\/wp\/v2\/categories?post=127"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.appblog.cn\/index.php\/wp-json\/wp\/v2\/tags?post=127"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}