android - '安卓 :paddingRight’ working with ‘android:drawableRight’

标签 android android-edittext padding

在 EditText 中,我在 EditText 的右侧放了一张图片, 我使用 FrameLayout 添加一个 TextView ,显示 Edittext 的剩余输入计数(如 p1 所示)。 p1

但是当输入太长时,它会与textview叠加,为了避免这种情况,我想使用android:paddingRight来保持输入字符留在左边,但结果就像p2 p2

如何使可绘制图标保持在右侧并且仅显示输入字符,例如 p3? enter image description here 谢谢。

最佳答案

这应该是一个替代示例,使用 RelativeLayout:

 <RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
     android:layout_width="fill_parent"
     android:layout_height="fill_parent">

     <EditText android:layout_width="fill_parent" android:layout_height="wrap_content"
          android:layout_alignParentLeft="true" android:layout_centerHorizontal="true"
          android:paddingRight="30dp"
          />


     <ImageView android:layout_width="20dp" android:layout_height="20dp"
         android:src="@drawable/your_image"
         android:layout_alignParentRight="true" android:layout_centerHorizontal="true"
         />

 </RelativeLayout>

关于android - '安卓 :paddingRight’ working with ‘android:drawableRight’ ,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/11325124/

相关文章:

android - 如何重新加载 future 数据的屏幕

android - Red5Pro调试Android Studio异常

android - YouTube API 在全屏模式下变为空白 - Android

android - İnflater 错误 Edittext while version has changed

android - 在编辑文本区域外部触摸时隐藏 android 中的键盘

带有提示的编辑文本中的 Android 辅助功能

css - firefox chrome 按钮的填充问题

grid - 如何减少基础网格中项目之间的空间?

java - 如何每分钟将我的 Firebase 数据库增加 1?

c - 使用 uint64_t 32 位和 64 位架构中的结构填充差异