android - 编辑文本大小不应改变 ImageView 的大小

标签 android android-layout android-edittext android-imageview

我有一个 ImageView ,下面有一个相对布局中的编辑文本

Edit-text的大小因输入任意几行文本而增加时, ImageView 的大小正在减小。

我想要的是我的文本应该重叠在 ImageView 上而不是!改变其大小。

请提出任何建议。

注意:我限制了编辑文本的高度和可滚动性。

这是代码:

<RelativeLayout
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:padding="5dp"
android:layout_width="match_parent"
android:layout_height="match_parent">

<com.myappp.custom_ui.RoundedImageView
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:background="#ffffff"
    android:id="@+id/selected_attachment"
    android:layout_marginTop="10dp"
    android:layout_marginBottom="10dp"
    android:layout_above="@+id/caption_holder"
    app:riv_corner_radius="8dp" />

<RelativeLayout
    android:layout_width="match_parent"
    android:id="@+id/caption_holder"
    android:background="@drawable/rounded_layout"
    android:layout_alignParentBottom="true"
    android:layout_height="wrap_content">
    <EditText
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:padding="10dp"
        android:capitalize="sentences"
        android:layout_centerVertical="true"
        android:layout_toLeftOf="@+id/send_attachement"
        android:background="@android:color/transparent"
        android:id="@+id/add_captionon_et"
        android:hint="Add caption"
        android:scrollbars="vertical"
        android:maxLines="3"/>
    <TextView
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:textSize="24sp"
        android:layout_alignParentRight="true"
        android:layout_centerVertical="true"
        android:padding="10dp"
        android:id="@+id/send_attachement"
        android:textColor="@color/myapp_theme_color"/>
</RelativeLayout>

最佳答案

问题出在使用android:layout_above="@+id/caption_holder"。它说 ImageView 位于 Caption_holder 之上,因此当 Caption_holder 调整大小时,ImageView 也会调整大小。

尝试删除此属性。

关于android - 编辑文本大小不应改变 ImageView 的大小,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/31585036/

相关文章:

android - IAB 错误您已经拥有此项目

Android自定义守护进程UI线程

android - 推文的 XML 布局

android - 我的 Edittext 开始不可见,如何在可见时使其可编辑?

android - 如何跨选项卡使用单个 fragment 中的 EditText?

android - 如何创建全彩色按钮?

android - 谷歌地图返回 nullpointerexception 谷歌地图 Android V2

Android android.view.InflateException 二进制 XML 文件行 #16 : Error inflating class fragment

android - 带有 Libgdx 屏幕的 LinearLayout 中的 Admob 横幅

android - 可搜索 ListView