【问题标题】:Align drawable to top-left corner in multiline edittext在多行edittext中将drawable对齐到左上角
【发布时间】:2015-07-17 16:46:28
【问题描述】:

我有一个drawable,我想将它与我的多行EditText 的左上角对齐。到目前为止,这是我所拥有的:

<EditText
    android:layout_width="match_parent"
    android:background="@android:color/transparent"
    android:layout_height="wrap_content"
    android:inputType="textMultiLine|textCapSentences"
    android:ems="10"
    android:drawableLeft="@drawable/ic_email_body"
    android:gravity="top|left"
    android:textColorHint="@color/hint_text"
    android:textColor="@color/text"
    android:hint="Compose"
    android:drawablePadding="10dp"
    android:id="@+id/email_body"
    android:layout_alignParentLeft="true"
    android:layout_alignParentStart="true"
    android:layout_alignRight="@+id/email_subject"
    android:layout_alignEnd="@+id/email_subject"
    android:layout_below="@+id/email_subject"
    android:layout_above="@+id/send_email"/>

这是它在 android studio 中的样子:

http://i.imgur.com/9eDEqUb.png

Compose 中的drawable EditTextEditText 的中间对齐,我希望它直接与单词旁边对齐,例如在“收件人”和“主题”字段中。

有什么办法可以做到这一点吗?是通过 XML 还是以编程方式?

【问题讨论】:

  • 我还希望使用 A ImageView 向左对齐和 EditText 向右对齐以更好地控制视图,
  • 谢谢你,效果很好。
  • 也谢谢你,我不知道我们可以在EditText里面有drawable,学到了一个新东西:D
  • @KlausCode 请看一下这个问题:stackoverflow.com/questions/33755041/…

标签: android layout android-edittext alignment drawable


【解决方案1】:

嗯,要获得与文本视图相同的样式,难道你不能只添加一个图像视图并简单地对齐它们吗?它看起来与该文本视图完全相同。可能更容易看到,因为据我所知没有明显的 drawabletopleft。

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2016-02-18
    • 1970-01-01
    • 2014-06-06
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多