Android 带圆角的TextInputLayout密码切换

Android 带圆角的TextInputLayout密码切换,android,android-layout,xamarin,android-design-library,android-textinputlayout,Android,Android Layout,Xamarin,Android Design Library,Android Textinputlayout,我正在使用android设计库25.1.1版的TextInputLayout。使用以下代码: <android.support.design.widget.TextInputLayout xmlns:android="http://schemas.android.com/apk/res/android" xmlns:local="http://schemas.android.com/apk/res-auto" android:layout_width="wrap_content

我正在使用android设计库25.1.1版的
TextInputLayout
。使用以下代码:

<android.support.design.widget.TextInputLayout
  xmlns:android="http://schemas.android.com/apk/res/android"
  xmlns:local="http://schemas.android.com/apk/res-auto"
  android:layout_width="wrap_content"
  android:layout_height="wrap_content"
  local:passwordToggleEnabled="true"
  local:hintEnabled="false">
  <android.support.design.widget.TextInputEditText
    android:id="@+id/confirmationEditText"
    android:singleLine="true" />
</android.support.design.widget.TextInputLayout>


如何设置密码开关的圆角半径?我是否可以引用其现有背景并使用所需的属性“包装”它(如何找到切换使用的默认可绘制路径)?

为此使用自定义形状:

  <shape xmlns:android="http://schemas.android.com/apk/res/android">
         <gradient
            android:endColor="@color/something"
            android:centerColor="@color/something_else"
            android:startColor="@color/something_else_still"
            android:angle="270" />
        <corners
            android:radius="3dp" />
        <padding
            android:left="10dp"
            android:top="10dp"
            android:right="10dp"
            android:bottom="10dp" />
    </shape>

我尝试在fresh project上实现,以了解您的场景

请看一下这个解决方案。我附上了它的屏幕截图

您必须将drawable包含在drawable文件夹中,并将其设置为textinputeditext

round_corner_toggle.xml


TextInputLayout的内容


我知道已经有一段时间了,但将此添加到您的TextInputLayout工作:

 app:boxCornerRadiusBottomEnd="20dp"
 app:boxCornerRadiusBottomStart="20dp"
 app:boxCornerRadiusTopEnd="20dp"
 app:boxCornerRadiusTopStart="20dp"

只需使用材质组件库和标准组件即可

添加
应用程序:boxCornerRadiusBottomEnd=“xxdp”
应用程序:boxCornerRadiusOpenD=“xxdp”
应用程序:boxCornerRadiusBottomStart=“xxdp”
应用程序:boxCornerRadiusTopStart=“xxdp”
属性

比如:

    <com.google.android.material.textfield.TextInputLayout
        style="@style/Widget.MaterialComponents.TextInputLayout.OutlinedBox"
        app:endIconMode="password_toggle"
        app:boxCornerRadiusBottomEnd="8dp"
        app:boxCornerRadiusTopEnd="8dp"
        app:boxCornerRadiusBottomStart="8dp"
        app:boxCornerRadiusTopStart="8dp"
        ...>
与:


@style/ShapeAppearanceOverlay.MyApp.TextInputLayout.Rounded
圆的
8dp

喜欢定制风格的作品。我还想给盒子添加一些阴影,但是运气不好。你也能帮我吗?谢谢:)
 app:boxCornerRadiusBottomEnd="20dp"
 app:boxCornerRadiusBottomStart="20dp"
 app:boxCornerRadiusTopEnd="20dp"
 app:boxCornerRadiusTopStart="20dp"
    <com.google.android.material.textfield.TextInputLayout
        style="@style/Widget.MaterialComponents.TextInputLayout.OutlinedBox"
        app:endIconMode="password_toggle"
        app:boxCornerRadiusBottomEnd="8dp"
        app:boxCornerRadiusTopEnd="8dp"
        app:boxCornerRadiusBottomStart="8dp"
        app:boxCornerRadiusTopStart="8dp"
        ...>
    <com.google.android.material.textfield.TextInputLayout
        android:id="@+id/custom_end_icon"
        android:hint="Hint text"
        style="@style/OutlinedRoundedBox"
        ...>
  <style name="OutlinedRoundedBox" parent="Widget.MaterialComponents.TextInputLayout.OutlinedBox">
    <item name="shapeAppearanceOverlay">@style/ShapeAppearanceOverlay.MyApp.TextInputLayout.Rounded</item>
  </style>

  <style name="ShapeAppearanceOverlay.MyApp.TextInputLayout.Rounded" parent="">
    <item name="cornerFamily">rounded</item>
    <item name="cornerSize">8dp</item>
  </style>