java如何正确对齐EditText光标?
我有一个200 SP大小的编辑文本。光标出现在中间。如何确保光标出现在左角?站在中间看起来很奇怪
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:安卓="http://schemas.安卓.com/apk/res/安卓"
安卓:orientation="vertical"
安卓:layout_width="fill_parent"
安卓:layout_height="fill_parent"
>
<EditText 安卓:layout_width="match_parent" 安卓:layout_height="wrap_content" 安卓:id="@+id/composeEditText" 安卓:minHeight="200sp" 安卓:focusable="true" 安卓:hint="Share an idea with the community"></EditText>
<LinearLayout 安卓:layout_width="match_parent" 安卓:layout_height="wrap_content" 安卓:id="@+id/toolbarLinearLayout">
<Button 安卓:layout_width="wrap_content" 安卓:layout_height="wrap_content" 安卓:id="@+id/sendButton" 安卓:text="Send"></Button>
<Button 安卓:layout_width="wrap_content" 安卓:layout_height="wrap_content" 安卓:id="@+id/shortenButton" 安卓:text="Shorten"></Button>
<TextView 安卓:layout_width="wrap_content" 安卓:layout_height="wrap_content" 安卓:id="@+id/charCountTextView" 安卓:text="140"></TextView>
</LinearLayout>
</LinearLayout>
# 1 楼答案
使用android:gravity=“上|左”
http://developer.android.com/reference/android/widget/TextView.html#attr_android:gravity
# 2 楼答案
我知道这是一个老帖子,可能当时不相关。。。 现在我们使用android:gravity=“top | start”或android:gravity=“bottom | start”
因此,它会将其与区域设置相匹配
# 3 楼答案
您应该使用^{} 属性: