在我的应用程序中,我正在使用Android Activity Slide过渡.我遵循了一个很好的教程,一切都按预期工作,除了我的提示EditText,其中包含InputTextLayout:
<android.support.design.widget.TextInputLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_margin="@dimen/activity_vertical_margin">
<EditText
android:layout_width="match_parent"
android:layout_height="match_parent"
android:hint="Your name"/>
</android.support.design.widget.TextInputLayout>
Run Code Online (Sandbox Code Playgroud)
所有组件都很好地动画,但提示只是在动画开始之前弹出并保持在最终位置.我是否必须添加一些额外的代码来告诉框架为该提示设置动画?
根据Android开发人员文档,它应该工作(或者至少它不是不受支持的).
我正在使用支持设计库的22.2版.
如果有人能指出我正确的方向,那就太棒了.
我在应用程序的登录页面中使用TextInputLayout UI机制,一切都很好,除了在这个设备上运行4.4.2 android版本的设备我有一个例外.
这是我的布局:
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="wrap_content">
<include android:id="@+id/loginInfiLogoRL"
layout="@layout/login_infi_logo_layout"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:paddingLeft="-3dp"
android:layout_marginTop="5dp"
android:layout_marginBottom="10dp"/>
<!--EMAIL-->
<android.support.design.widget.TextInputLayout
android:id="@+id/email_wrapper"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_below="@+id/loginInfiLogoRL"
android:theme="@style/TextLabel">
<EditText
android:id="@+id/etUserName"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:hint="@string/login_screen_email_hint"
android:imeOptions="actionNext"
android:inputType="textEmailAddress"
android:maxLines="1"
android:nextFocusDown="@+id/etPassword"
android:singleLine="true"
android:textColor="@android:color/white"
android:textColorHighlight="@color/Orange"
android:textColorHint="@android:color/white" />
</android.support.design.widget.TextInputLayout>
<RelativeLayout
android:id="@+id/rlPassword"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="12dp"
android:layout_below="@id/email_wrapper">
<!--PASSWORD-->
<android.support.design.widget.TextInputLayout
android:id="@+id/password_wrapper"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:theme="@style/TextLabel">
<EditText
android:id="@+id/etPassword"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:hint="@string/login_screen_password_hint"
android:imeOptions="actionNext"
android:inputType="textPassword"
android:maxLines="1"
android:nextFocusDown="@+id/bSignIn"
android:shadowColor="@color/Orange"
android:singleLine="true"
android:textColor="@android:color/white"
android:textColorHint="@android:color/white" />
</android.support.design.widget.TextInputLayout>
<!--FORGOT-->
<TextView
android:id="@+id/tvForgotPassword"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentEnd="true"
android:layout_alignParentRight="true"
android:layout_centerInParent="true"
android:paddingBottom="14dp"
android:paddingRight="10dp"
android:text="@string/login_screen_forgot_password_text"
android:textColor="@color/Orange" …Run Code Online (Sandbox Code Playgroud) android colors android-edittext inflate-exception android-textinputlayout
我想将一个带有背景的EditText作为"普通"EditText,但是对TextInputEditText进行错误处理(错误消息显示在底部,而不是"!"drawable出现).
我有这样的事情:
<android.support.design.widget.TextInputLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
app:setError="@{viewModel.error}">
<android.support.design.widget.TextInputEditText
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="@drawable/simple_edit_text_background"
android:ellipsize="end"
android:inputType="textMultiLine|textNoSuggestions"
android:text="@={viewModel.value}"
style="@style/MyEditTextStyle" />
</android.support.design.widget.TextInputLayout>
Run Code Online (Sandbox Code Playgroud)
但似乎当我在TextInputLayout上设置错误时,它将背景drawable(在普通的TextInputEditText中,下划线)更改为错误TextView的颜色.
我们可以在以下方法中的TextInputLayout代码中看到它:
private void updateEditTextBackground() {
if (mEditText == null) {
return;
}
Drawable editTextBackground = mEditText.getBackground();
if (editTextBackground == null) {
return;
}
ensureBackgroundDrawableStateWorkaround();
if (android.support.v7.widget.DrawableUtils.canSafelyMutateDrawable(editTextBackground)) {
editTextBackground = editTextBackground.mutate();
}
if (mErrorShown && mErrorView != null) {
// Set a color filter of the error color
editTextBackground.setColorFilter(
AppCompatDrawableManager.getPorterDuffColorFilter(
mErrorView.getCurrentTextColor(), PorterDuff.Mode.SRC_IN));
} else if (mCounterOverflowed && mCounterView != null) {
// Set …Run Code Online (Sandbox Code Playgroud) 是否可以更改 OutlinedTextField 的边框半径。我想实现这样的目标

我无法使用 Modifier.border 因为它只是在标签上方绘制边框。像这样

对于 OutlinedTextField 来说,没有像 TextField 中那样的形状参数。如果我使用简单的 TextField,我就无法在顶部边框线中绘制标签。标签在文本字段内绘制。
android android-textinputlayout android-jetpack-compose android-compose-textfield
我注意到TextInputLayout的一些奇怪的行为:
当我在布局中添加以下内容时:
<android.support.design.widget.TextInputLayout
android:layout_width="match_parent"
android:layout_height="wrap_content">
<EditText
android:id="@+id/txtFirstName"
style="@style/EditTextStyle"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:hint="In layout"
android:singleLine="true" />
</android.support.design.widget.TextInputLayout>
Run Code Online (Sandbox Code Playgroud)
一切都按预期工作.
当我给类似的布局充气时:
View v = LayoutInflater.from(this).inflate(R.layout.edittext_w_surrounding_textinputlayout, null);
EditText editText = (EditText) v.findViewById(R.id.editText);
editText.setHint("Added programmatically");
ViewGroup root = (ViewGroup) findViewById(R.id.root);
root.addView(v);
Run Code Online (Sandbox Code Playgroud)
在TextInputLayout没有出现和EditText的行为的标准方式.
任何想法可能是什么原因?

我正在创建简单的AppCompatEditText,添加OnFocusChangeListener并将其放在简单的TextInputLayout中.
当AppCompatEditText失去焦点时,它的内容应该通过isValidParam方法验证.
它工作到昨天,当我使用rev.23.0.3但是现在,当我使用rev.24.0.2时,它在isValidParam方法的第1行给出如下错误.
java.lang.ClassCastException:android.widget.FrameLayout无法强制转换为android.support.design.widget.TextInputLayout
我检查了调试模式.AppCompatEditText.getpParent()确实返回Framelayout而不是TextInputLayout.
LinearLayout llParams = new LinearLayout(context);
llParams.setOrientation(LinearLayout.VERTICAL);
// Create label for param
final TextInputLayout tilParam = new TextInputLayout(context);
// Add label into layout
llParams.addView(tilParam);
// Create Editor for param
final AppCompatEditText etParam = new AppCompatEditText(context);
edParam.setOnFocusChangeListener(new View.OnFocusChangeListener() {
@Override
public void onFocusChange(View v, boolean hasFocus) {
if (!hasFocus)
if (isValidParam(etParam)) {
do some thing;
} else {
do other thing;
}
}
});
tilParam.addView(etParam);
// validation method
boolean isValidParam(AppCompatEditText editText) {
TextInputLayout til = (TextInputLayout) editText.getParent(); …Run Code Online (Sandbox Code Playgroud) android android-appcompat android-design-library android-textinputlayout textinputlayout
正如你在图片中看到的,我有一个黑色背景和白色文本的Android应用程序.然而实际上有一个"显示文本"图标看起来像一个"眼睛",它也是黑色的:(.有没有办法改变这个颜色?
activity_login.xml
<?xml version="1.0" encoding="utf-8"?>
<ScrollView xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:fitsSystemWindows="true"
android:background="@color/black">
<LinearLayout
android:orientation="vertical"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:paddingTop="56dp"
android:paddingLeft="24dp"
android:paddingRight="24dp">
<ImageView android:src="@drawable/logo"
android:layout_width="wrap_content"
android:layout_height="72dp"
android:layout_marginBottom="24dp"
android:layout_gravity="center_horizontal" />
<!-- Email Label -->
<android.support.design.widget.TextInputLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="8dp"
android:layout_marginBottom="8dp"
android:textColorHint="#ffffff">
<EditText android:id="@+id/input_email"
android:theme="@style/MyEditTextTheme"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:inputType="textEmailAddress"
android:hint="E-Mail Address"/>
</android.support.design.widget.TextInputLayout>
<!-- Password Label -->
<android.support.design.widget.TextInputLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="8dp"
android:layout_marginBottom="8dp"
android:textColor="#ffffff"
android:textColorHint="#ffffff">
<EditText android:id="@+id/input_password"
android:theme="@style/MyEditTextTheme"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:inputType="textPassword"
android:hint="Password"/>
</android.support.design.widget.TextInputLayout>
<android.support.v7.widget.AppCompatButton
android:id="@+id/btn_login"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_marginTop="24dp"
android:layout_marginBottom="24dp"
android:padding="12dp"
android:text="Login"/>
<TextView android:id="@+id/link_signup"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_marginBottom="24dp"
android:text="No account yet? Create …Run Code Online (Sandbox Code Playgroud) 嗨,我需要删除我的 TextField 中的下划线,因为当 TextField 是圆形时它看起来很难看。我已经将 activeColor 设置为透明,但是光标不会显示(因为它是透明的)。如何删除下划线/activeColor 并保留光标?
这是我的循环文本字段代码:
@Composable
fun SearchBar(value: String) {
// we are creating a variable for
// getting a value of our text field.
val inputvalue = remember { mutableStateOf(TextFieldValue()) }
TextField(
// below line is used to get
// value of text field,
value = inputvalue.value,
// below line is used to get value in text field
// on value change in text field.
onValueChange = { inputvalue.value = it },
// below line …Run Code Online (Sandbox Code Playgroud) android android-textinputlayout android-jetpack-compose android-compose-textfield android-jetpack-compose-text