我想要EditText上图中的那个。问题是,如果我使用TextInputLayout它在底部显示默认栏,我希望它周围有自定义边框。
我也尝试使用以下示例,
我想删除AutoCompleteTextView在我使用TextInputLayout和使用样式时创建的下拉箭头:ExposedDropdownMenu

下面是我的代码:
<com.google.android.material.textfield.TextInputLayout
android:layout_marginTop="10dp"
style="@style/Widget.MaterialComponents.TextInputLayout.OutlinedBox.ExposedDropdownMenu"
android:hint="Marital Status"
android:layout_width="match_parent"
android:layout_height="match_parent"
app:boxStrokeColor="@color/colorPrimaryDark">
<AutoCompleteTextView
android:background="@null"
android:focusable="false"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:id="@+id/edt_marital" />
</com.google.android.material.textfield.TextInputLayout>
Run Code Online (Sandbox Code Playgroud) android autocompletetextview android-textinputlayout material-components material-components-android
我在clojurescript中使用反应原生物在android上编写一个计时器应用程序(使用试剂希望不重要).
我有一个TextInput地方,我接受用户的文字来命名计时器.每当我的计时器打勾,整个Android应用程序重新渲染,我就会失去焦点TextInput.我目前正在使用onChangeText保存我正在键入的字符,有没有办法在计时器滴答作响时保持对文本输入的关注?
谢谢.
我需要在app中创建字段编辑页面.有编辑联系人的EditText列表.对于每种字段类型,我都有一个布局.例如 - 对于名称和姓氏,它是浮动标记的编辑文本.对于Facebook - 简单的编辑文本与图标.我正在使用Android数据绑定库创建此列表
我已经创建了布局
<data>
<variable
name="item"
type="app.core.db.model.Field" />
</data>
<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical">
<android.support.design.widget.TextInputLayout
android:layout_width="match_parent"
android:layout_height="65dp"
app:hintTextAppearance="@style/TextAppearence.App.TextInputLayout"
app:theme="@style/EditFieldFloatLabeled">
<EditText
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:ellipsize="end"
android:hint="@{item.getHint()}"
android:imeOptions="actionNext"
android:maxLines="1" />
</android.support.design.widget.TextInputLayout>
</FrameLayout>
Run Code Online (Sandbox Code Playgroud)
但浮动标签不起作用.我开始逐行评论以找出原因.当我评论线时,浮动标签变得有效
android:hint="@{item.getHint()}
Run Code Online (Sandbox Code Playgroud)
(并用硬编码文本替换它).根据字段类型getHint()返回R.string.{something}.
在那里我发现了比以编程方式设置提示产生浮动标签消失.我不能使用静态布局(而不是回收者视图),因为字段列表可能会出现dynsmically(例如:我在字段中写入电话号码,而在其后为其他电话号码插入空电话字段).
有没有办法以相同的方式创建浮动标签(通过使用字段类型定义提示)?
data-binding android android-textinputlayout android-databinding
我想改变 TEXT INPUT LAYOUT 中的提示颜色,当它处于聚焦或未聚焦状态时相同。我有两个 TEXT INPUT LAYOUT 字段。两个字段都是相同的颜色。但它在聚焦状态颜色出现,但在未聚焦状态下为默认值灰色出现。我想在聚焦和未聚焦状态下保持提示的颜色相同。
<com.example.viveka.snipeid.CustomTextInputLayout
android:id="@+id/input_layout_name"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="15dp"
app:errorEnabled="true"
>
<EditText
android:id="@+id/editEmail"
android:layout_width="match_parent"
android:layout_height="40dp"
android:hint="email / snipe id"
android:digits="abcdefghijklmnopqrstuvwxyz.@0123456789"
android:textAllCaps="false"
android:textSize="12sp"
android:layout_marginLeft="-4dp"
android:textColor="@color/lightgray"
android:textColorHint="@color/primary"/>
</com.example.viveka.snipeid.CustomTextInputLayout>
Run Code Online (Sandbox Code Playgroud)
我需要将两个字段更改为相同的颜色..
android android-layout android-edittext android-textinputlayout
我正在尝试将这些材料文本字段与框轮廓样式一起使用。我看到有一个名为的属性boxStrokeColor,它允许我仅在文本字段突出显示时设置笔划 ,而未突出显示它似乎从全局主题的colorPrimary值中提取该颜色。
在我们的应用程序中,用户可以为某些视图设置自己的背景颜色,我想将文本字段的笔触颜色更改为合适的对比色。
有没有干净的方法来以编程方式设置未突出显示的框笔触颜色?
android android-textinputlayout material-components material-components-android
我正在为 RecyclerView 项目使用环绕 EditText 的 TextInputLayout 。我正在使用样式“Theme.AppCompat.Light.NoActionBar”。但我仍然收到错误“由:java.lang.IllegalArgumentException:此组件上的样式要求您的应用主题为 Theme.AppCompat(或后代)”。 但是,当我从 xml 中删除 TextInputLayout 时,应用程序运行良好。
这是我的 RecyclerView 项目(item_content_settings):
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal"
android:weightSum="20">
<com.google.android.material.textfield.TextInputLayout
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="18"
android:padding="16dp">
<EditText
android:id="@+id/content_summary"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:hint="First Name"
android:inputType="text"
android:text="First Name And Last Name" />
</com.google.android.material.textfield.TextInputLayout>
<ImageView
android:id="@+id/pencil"
android:layout_width="0dp"
android:layout_height="16dp"
android:layout_gravity="center"
android:layout_margin="0dp"
android:layout_weight="2"
android:src="@drawable/pencil_edit" />
</LinearLayout>
Run Code Online (Sandbox Code Playgroud)
我的风格:
<resources>
<!-- Base application theme. -->
<style name="AppTheme" parent="AppTheme.Base">
<!-- Customize your theme here. -->
<item name="colorPrimary">@color/colorPrimary</item>
<item name="colorPrimaryDark">@color/colorPrimaryDark</item>
<item name="colorAccent">@color/colorAccent</item>
</style>
<style name="AppTheme.Base" …Run Code Online (Sandbox Code Playgroud) android android-layout android-theme android-textinputlayout material-components-android
在 TextInputLayout 我想通过自定义类添加 TextInputEditText 这是我创建的自定义类的代码:
public class CustomTextInputEditText extends TextInputLayout {
private TextInputEditText editText;
public CustomTextInputEditText(@NonNull Context context) {
this(context, null);
}
public CustomTextInputEditText(@NonNull Context context, @Nullable AttributeSet attrs) {
this(context, attrs, R.style.Widget_MaterialComponents_TextInputLayout_OutlinedBox);
}
public CustomTextInputEditText(@NonNull Context context, @Nullable AttributeSet attrs, int defStyleAttr) {
super(context, attrs, defStyleAttr);
init(context, attrs, defStyleAttr);
}
private void init(Context context, AttributeSet attrs, int defStyleAttr) {
removeAllViews();
setWillNotDraw(false);
editText = new TextInputEditText(getContext());
createEditBox(editText);
}
private void createEditBox(TextInputEditText editText) {
LinearLayout.LayoutParams layoutParams = new LinearLayout.LayoutParams(LayoutParams.MATCH_PARENT, LayoutParams.MATCH_PARENT);
editText.setPadding(0,10,0,0); …Run Code Online (Sandbox Code Playgroud) 如何将文本输入布局轮廓框样式中的浮动提示的背景颜色更改为透明。我认为所附图片清楚地说明了问题应该在笔划上方为红色,下方为白色)。我为改变背景本身所做的是:
<style name="App.TextInputLayout" parent="Widget.MaterialComponents.TextInputLayout.OutlinedBox.Dense">
<item name="boxBackgroundColor">@color/white</item>
</style>
Run Code Online (Sandbox Code Playgroud)
任何帮助是极大的赞赏
android background android-edittext material-design android-textinputlayout
一般来说,Jetpack Compose 中的大多数组件似乎都非常容易定制。
但是,对于TextField. 例如,假设我想做这样的事情:
人们会认为简单地包装BaseTextField会起作用。不过貌似BaseTextField组件有bug ,我开了个issue。在重新渲染组件之前,此错误将不允许用户在焦点远离文本字段后聚焦文本字段。
引用这一点,我尝试自定义OutlinedTextField和TextField组件,但无法自定义它们以看起来像上图。如果不是因为光标颜色使用了该activeColor属性,我可以让它工作。
创建一个类似上面的可用文本字段的正确解决方法是什么?
android android-textinputlayout android-jetpack android-jetpack-compose
android ×10
material-components-android ×3
background ×1
cljsrn ×1
data-binding ×1
react-native ×1