我有一行EditText,当我设置一个长提示时,提示换行到两行.我可以强制EditText总是一行高吗?android:lines="1"没用.
在写这个问题之前,我已经阅读了以下答案/文章:
Android软键盘默认设置为平移,这意味着它将保持键盘上方的所有可编辑区域.然而,它不泛不够.当我运行它并按下靠近屏幕底部的edittext时,键盘出现并且edittext向上移动但不足以查看其中键入的内容.我用过/试过以下内容:
android:windowSoftInputMode="adjustPan"在活动的清单中.这没有任何区别.我也试图把价值观adjustUnspecified和adjustResize太.它们都不起作用.
<uses-sdk android:minSdkVersion="3" />在清单文件中.我的应用程序针对sdk 2.1及更高版本.尽管如此,我尝试过它并没有奏效.
使用ScrollView.也不起作用.
有没有办法手动管理按下特定编辑文本时键盘执行多少"平移".
下面是我的xml文件.
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:background="#ffffff">
<ImageView
android:id="@+id/header"
android:layout_width="320dip"
android:layout_height="86dip"
android:background="@drawable/header_bg">
</ImageView>
<ImageView
android:layout_width="320dip"
android:layout_height="200dip"
android:layout_alignParentBottom="true"
android:background="@drawable/bg1_btm">
</ImageView>
<TextView android:text="Hostname"
android:id="@+id/lbl_hostname"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="@id/header"/>
<TextView android:text="(Current)"
android:id="@+id/lbl_hostname_current"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_toRightOf="@id/lbl_hostname"
android:layout_below="@id/header" />
<EditText android:text="EditText"
android:id="@+id/editText_hostname"
android:layout_below="@id/lbl_hostname"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:maxLength="25">
</EditText>
<TextView android:text="Registration URL"
android:id="@+id/lbl_registration"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="@id/editText_hostname" />
<TextView android:text="(Current)"
android:id="@+id/lbl_registration_current"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="@id/editText_hostname"
android:layout_toRightOf="@id/lbl_registration" />
<TextView android:text="http://"
android:id="@+id/lbl_url_prefiz" …Run Code Online (Sandbox Code Playgroud) 我有一个用户名和密码XML段
<EditText
android:id="@+id/username"
android:hint="@string/username_hint"
android:layout_width="match_parent"
android:maxLength="9"
android:nextFocusDown="@+id/pswd"
android:layout_height="wrap_content">
</EditText>
<EditText
android:inputType="textPassword"
android:hint="@string/password_hint"
android:id="@+id/pswd"
android:layout_width="match_parent"
android:layout_height="wrap_content">
</EditText>
Run Code Online (Sandbox Code Playgroud)
我希望当用户名字段到达第9个字符时,光标焦点会自动跳转到密码字段
我正在自动查看Focus next textview并尝试:
final EditText usr = (EditText) findViewById (R.id.username);
final EditText pswd = (EditText) findViewById (R.id.pswd);
usr.addTextChangedListener(new TextWatcher() {
public void onTextChanged(CharSequence s, int start, int before, int count) {
if (s.length() == 9) {
pswd.requestFocus();
}
}
@Override
public void afterTextChanged(Editable arg0) {
}
@Override
public void beforeTextChanged(CharSequence s, int start,
int count, int after) {
} …Run Code Online (Sandbox Code Playgroud) 我有TextField从它的正常单行宽度和高度扩展但是当我改变文本字段的高度时,开始在EditText中键入的光标始终位于扩展文本字段的中心,这也是它开始放置文本的位置.
如何在保持较大高度的盒子的同时将光标像正常一样放在左上角?
这就是我的盒子布局
<EditText
android:id="@+id/editText1"
android:layout_width="match_parent"
android:layout_height="200dp"
android:layout_alignParentLeft="true"
android:layout_below="@+id/camera_picture"
android:layout_marginTop="58dp"
android:ems="10"
android:inputType="textMultiLine" >
<requestFocus />
</EditText>
Run Code Online (Sandbox Code Playgroud) 我目前正在开发一款带有三星Galaxy Tab 2的应用程序作为我的设备.
我在XML中的代码是:
<EditText
android:id="@+id/analysis_text"
style="@style/icon_text"
android:imeOptions="actionDone"
android:inputType="textMultiLine"
android:onClick="onBtnClicked"
/>
Run Code Online (Sandbox Code Playgroud)
执行此代码时,仅在某些情况下会自动触发全屏数据输入模式(提取模式).
我希望我的用户在编辑此控件中的文本时获得完整的数据输入屏幕,无论屏幕或控件的位置如何.
这个问题的另一个改述:无论内容是什么,如何在我的活动中强制使用EditText框的全屏数据输入模式?
我读到Android会EditText在应用程序即将停止或终止时自动保存对象的内容.但是,在我的应用程序中,EditText当屏幕方向改变时,a的内容会丢失.
这是正常的行为吗?然后我必须用onSaveInstanceState/ 手动保存/恢复其内容onRestoreInstanceState吗?或者是否有更简单的方法告诉Android保存它还原它?
编辑:
我以EditText编程方式创建对象,而不是XML.事实证明这与问题有关(见下面接受的答案).
我想setError什么时候TextInputLayout isEmpty,我写这段代码但是当显示错误信息时,设置红色背景TextInputLayout!
我不想要设置背景!我只想显示错误消息.
我的代码:
if (TextUtils.isEmpty(userName)) {
register_UserName_layout.setError("Insert Username");
}
Run Code Online (Sandbox Code Playgroud)
XML代码:
<android.support.design.widget.TextInputLayout
android:id="@+id/register_userUsernameTextLayout"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_below="@+id/register_headerLayout"
android:layout_margin="10dp"
android:textColorHint="#c5c5c5">
<EditText
android:id="@+id/register_userUserNameText"
android:layout_width="match_parent"
android:layout_height="40dp"
android:background="@drawable/selector_bg_edit"
android:hint="??? ??????"
android:paddingBottom="2dp"
android:textColor="@color/colorAccent"
android:textCursorDrawable="@drawable/bg_input_cursor"
android:textSize="16sp" />
</android.support.design.widget.TextInputLayout>
Run Code Online (Sandbox Code Playgroud)
我怎样才能解决这个问题?谢谢所有<3
我有一个EditText作为密码输入
<android.support.design.widget.TextInputLayout
android:layout_width="match_parent"
android:layout_height="wrap_content">
<EditText
android:id="@+id/password"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:hint="@string/prompt_password"
android:imeActionId="@+id/login"
android:imeActionLabel="@string/action_sign_in_short"
android:imeOptions="actionUnspecified"
android:inputType="textPassword"
android:maxLines="1"
android:singleLine="true" />
</android.support.design.widget.TextInputLayout>
Run Code Online (Sandbox Code Playgroud)
它正在工作,但是当出现错误时,错误图标会显示两次,并且它位于显示密码图标的顶部.
我的验证码显示错误:
if (success) {
finish();
startMainActivity();
} else {
mPasswordView.setError(getString(R.string.error_incorrect_password));
mPasswordView.requestFocus();
}
Run Code Online (Sandbox Code Playgroud) 我EditText在调用时遇到错误指示器位置的问题editText.setError("...").
正如您在屏幕截图中看到的,我正在使用它BottomSheetDialog的EditText内部.当我显示错误指示符时,文本完全不合适.似乎对话框"认为"它是全屏的,而实际上并非如此.
这是我的对话框布局文件(phone_dialog.xml):
<android.support.constraint.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_weight="0"
android:orientation="vertical">
<TextView
android:id="@+id/tvTitle"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="8dp"
android:gravity="center"
android:padding="@dimen/padding_layout_normal"
android:text="@string/dialog_title_edit_phone"
app:layout_constraintLeft_toLeftOf="parent"
app:layout_constraintRight_toRightOf="parent"
app:layout_constraintTop_toTopOf="parent"
/>
<EditText
android:id="@+id/etPhone"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="8dp"
android:gravity="center"
android:inputType="phone"
app:layout_constraintLeft_toLeftOf="parent"
app:layout_constraintRight_toRightOf="parent"
app:layout_constraintTop_toBottomOf="@+id/tvTitle"/>
<Button
android:id="@+id/btnSavePhone"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginLeft="0dp"
android:layout_marginRight="0dp"
app:layout_constraintLeft_toLeftOf="parent"
app:layout_constraintRight_toRightOf="parent"
app:layout_constraintTop_toBottomOf="@+id/etPhone"/>
</android.support.constraint.ConstraintLayout>
Run Code Online (Sandbox Code Playgroud)
我的Activity布局文件(activity_contacts.xml):
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical">
<android.support.v7.widget.RecyclerView
android:id="@+id/rvContacts"
android:layout_width="match_parent"
android:layout_height="match_parent"/>
</LinearLayout>
Run Code Online (Sandbox Code Playgroud)
这就是我显示对话框的方式Activity:
PhoneBottomDialog dialog = new PhoneBottomDialog(Context);
dialog.show();
Run Code Online (Sandbox Code Playgroud)
这是我的PhoneBottomDialog班级:
public …Run Code Online (Sandbox Code Playgroud) 我的问题与android功能相关,缩放由多个子视图组成的父级.
ZoomView-> ParentView - > [多个childViews]
我正在开发一个Demo项目来缩放子视图并无限地平移.缩放可以根据需要完美地工作.
问题1: 但是如果视图中有一个EditText,我试着放大,那么我面临下面的问题.
选择文本也存在上述问题.
如果不清楚,请尝试运行演示以了解问题
我尝试了两种缩放View内容的方法,但这两种方法都给出了同样的问题.
我的演示项目的层次结构缩放视图(UML图)
基本问题是当视图缩放到某个值时将光标放在正确的位置.
我已经提到了这个帖子
问题2: 如果我有一个childView这是在父视图移动,然后缩小,如果childView翻译的事件不再捕捉parentView的范围和子视图外后成为碰不得我一直在使用TouchDelegate尝试,但我不我知道如何扩展parentView触摸区域.代码 参考线程
scale为1,区域触摸区域等于parentView和ZoomView的屏幕
但是当比例因子不等于1时,父项的触摸区域(zoomIn)小于显示的ZoomView
黄色 - 父查看触摸区域
Cyan-ZoomView触摸区域
Green-ChildView触摸区域
ScreenShot在这里
注意: 这是我关于StackOverflow的第一个问题所以请建议是否需要进行一些编辑.
android ×10
android-edittext ×10
bottom-sheet ×1
bundle ×1
dialog ×1
focus ×1
fullscreen ×1
hidden ×1
hide ×1
keyboard ×1
mode ×1
scale ×1
view ×1