我知道这个问题被问过很多次了。但没有一个例子对我有用。
我想通过XML文件将光标位置设置在中心。
我怎样才能做到这一点??
我当前的光标位置如下图所示。
我的 XML 文件代码如下
.XML 文件
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical" >
<EditText
android:id="@+id/sigupDisplayName"
style="@style/editTextStyle"
android:layout_width="match_parent"
android:layout_height="40dp"
android:background="@drawable/edittext_style"
android:ems="10"
android:gravity="center"
android:hint="@string/display_name" >
<requestFocus />
</EditText>
</LinearLayout>
最佳答案
我现在发现主要问题是什么...
问题出在 API 级别..
我更改了程序的 API 级别。
在 API 15 以下,光标设置在我的应用程序的中心..
从 API 16 开始,光标位置设置为提示文本的开头...!!!
关于android - 将编辑文本的光标位置设置在中心...!,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/28322619/