【问题标题】:Displaying image in extream side of EditText android在EditText android的极端侧显示图像
【发布时间】:2017-10-07 06:24:28
【问题描述】:
 <EditText
                    android:layout_width="match_parent"
                    android:layout_height="45sp"
                    android:layout_marginTop="10sp"
                    android:textColor="#000"
                    android:id="@+id/main_email_tv"
                    android:inputType="textCapWords"
                    android:hint="Email"
                    android:textSize="25sp"
                    android:drawableRight="@drawable/lock"

                    />

我在右侧的edittext中添加锁定图像,但问题是我无法在edittext中调整图像大小。

其实我一直在寻找这个选项,最后得到了。 android:drawableLeft="@drawable/pic 通过此选项,可以在 EditText 的最左侧显示图像。 对于其他正在寻找相同答案的人,必须确保图像的大小应在 25-35px 左右,否则图像将无法在 editetxt 中正确显示。

【问题讨论】:

  • 你想要图片在这个edittext的右边还是在edittext的右边?
  • @amit Sir 我想把edittext里面的图片放到右边
  • 那是不可能的,你需要获取edittext的其他imagiview权限
  • 是的,它可以在 righthandside.left 或任何地方,但不能在里面!
  • Sir image 已经在 edittext 里面了,问题是可调整性。如何使它像宽度 = 10sp 和高度 = 10sp 一样小

标签: android xml layout android-edittext


【解决方案1】:

像这样设置你的图像

                   <LinearLayout
                    android:layout_width="match_parent"
                    android:layout_height="50dp"
                    android:layout_marginTop="30dp"
                   >

                    <EditText
                        android:id="@+id/edt_dob"
                        android:layout_width="0dp"
                        android:layout_height="match_parent"

                        android:layout_gravity="center_vertical"
                        android:layout_weight="1"
                        android:background="@null"
                        android:editable="false"
                        android:focusable="false"
                        android:hint="Date Of Birth"
                        android:paddingLeft="10dp"
                        android:textColor="#ffffff"
                        android:textColorHint="#ffffff" />

                    <ImageView
                        android:id="@+id/img_date"
                        android:layout_width="35dp"
                        android:layout_height="35dp"
                        android:layout_gravity="center_vertical"
                        android:layout_marginRight="10dp"
                        android:src="@drawable/calendar" />


                </LinearLayout>

【讨论】:

  • stackoverflow.com/questions/15002963/… 先生,在这个 url 中查看图片,查看用户名和密码左侧的图片,我希望在正确的方向上也一样
  • 你有两个选择。要么你必须把你的图像作为你需要的高度和宽度。或者你也可以按照上面的方法。它会做你想做的事
【解决方案2】:

使用这个而不是单独使用EditText

<RelativeLayout 
    android:layout_width="fill_parent"
    android:layout_height="45sp"
    android:layout_marginTop="10sp">

    <EditText  
        android:layout_width="fill_parent" 
        android:layout_height="wrap_content"
        android:layout_marginTop="10dp"
        android:layout_marginBottom="10dp"
        android:gravity="center"
        android:textStyle="bold"
        android:textSize="17sp"
        android:text="How to select and crop image"/>


    <ImageView
        android:id="@+id/iv_photo"
        android:layout_marginTop="10dp"
        android:layout_gravity="center_horizontal"
        android:layout_width="fill_parent"       
        android:layout_height="200dp"/>

</RelativeLayout>

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2019-09-03
    • 1970-01-01
    • 1970-01-01
    • 2020-05-16
    • 2019-06-26
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多