Android 调整平移剪切编辑文本的底部
似乎Android 调整平移剪切编辑文本的底部,android,Android,似乎adjustPan实际上是在我的EditText的基线上进行平移,而不是在视图的实际边缘 我一直在寻找一种方法来解决这个问题,但我就是找不到任何东西 活动代码(kotlin): 布局xml: <android.support.constraint.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android" xmlns:app="http://schemas.android.c
adjustPan
实际上是在我的EditText
的基线上进行平移,而不是在视图的实际边缘
我一直在寻找一种方法来解决这个问题,但我就是找不到任何东西
活动代码(kotlin):
布局xml:
<android.support.constraint.ConstraintLayout
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
tools:context="com.foo.testbed.MainActivity">
<EditText
android:id="@+id/myEditText"
android:layout_width="0dp"
android:layout_height="48dp"
android:layout_marginBottom="8dp"
android:layout_marginEnd="15dp"
android:layout_marginStart="8dp"
android:background="@drawable/rounded_edit_text"
android:hint="Message"
android:paddingStart="8dp"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toStartOf="@id/myButton"
app:layout_constraintStart_toStartOf="parent" />
<Button
android:id="@+id/myButton"
android:layout_width="wrap_content"
android:layout_height="48dp"
android:layout_marginBottom="8dp"
android:layout_marginEnd="8dp"
android:text="Send"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintTop_toTopOf="@id/myEditText" />
解决方案是设置顶部和底部填充物
我的editText示例:
<AutoCompleteTextView
android:id="@+id/editText_new_password"
android:layout_width="match_parent"
android:layout_height="@dimen/btn_editbox_height"
android:background="@drawable/edit_text_style"
android:gravity="center_vertical"
android:paddingEnd="@dimen/login_edit_box_pass_padding_right"
android:paddingTop="10dp"
android:paddingBottom="10dp"
android:paddingStart="@dimen/edit_box_padding"
android:textSize="14sp" />
带衬垫12:
和裸垫:
AdjustPan仅承诺光标将在视图中,而不是整个编辑文本。这个问题没有解决办法,它按预期工作,也没有办法改变它的工作方式。@nukeforum发现了什么吗?@iCantC可以找到或修改一个更常见的答案。从本质上说,将布局包装为可滚动的布局可以使布局稍微调整以正确显示。这不是一个完美的解决方案,但它确实解决了我的问题。非常感谢。
<AutoCompleteTextView
android:id="@+id/editText_new_password"
android:layout_width="match_parent"
android:layout_height="@dimen/btn_editbox_height"
android:background="@drawable/edit_text_style"
android:gravity="center_vertical"
android:paddingEnd="@dimen/login_edit_box_pass_padding_right"
android:paddingTop="10dp"
android:paddingBottom="10dp"
android:paddingStart="@dimen/edit_box_padding"
android:textSize="14sp" />