Android TextView 未在 ImageView 下方对齐

标签 android xml textview imageview

<TextView android:text="ABC" 
    android:layout_width="wrap_content"
    android:layout_height="wrap_content" />

下面的代码应该将文本对齐到图像下方的右下角。但这并没有发生

<TextView
    android:text="XYZ"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:layout_below="@id/pic"
    android:layout_alignParentBottom="true"
    android:layout_alignParentRight="true"/>

<ImageView
    android:src="@drawable/androidparty"
    android:layout_height="wrap_content"
    android:layout_width="wrap_content"
    android:id="@+id/pic"/>

最佳答案

Android TextView not aligning below ImageView

TextView 未在 ImageView 下方对齐,因为 TextView 的 alignParentBottom 属性设置为 true

从 TextView 中移除 alignParentBottom 属性:

<TextView
    ....
    android:layout_below="@id/pic" 
    android:layout_alignParentRight="true"/>

关于Android TextView 未在 ImageView 下方对齐,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/31229535/

相关文章:

android - 拉动刷新recyclerview android

android - Mac OS Flutter 构建 appbundle 失败 : Invalid keystore format

android - 将 Flutter with Fabric 分发给 Beta 测试人员

xml - XPath 表达式获取所有前面的兄弟 UNTIL 条件满足

java - 如何从 xml 文件中获取字符串形式的 URL?

android - react native promise

java - 如何禁用java节点的特殊字符转义

android - ConstraintLayout TextView

java - 尝试将 setText() 设置为 TextView 时强制关闭应用程序

android - Android Listview 中的编辑模式