【问题标题】:Aligning text with picture文字与图片对齐
【发布时间】:2017-05-09 03:28:07
【问题描述】:

我有以下 recyclerview。如您所见,文本与每行中的图像不对齐。

我的 xml 是

<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:padding="2dp"
android:id="@+id/relLayout">

<TextView
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:text="New Text"
    android:textStyle="bold"
    android:textSize="15dp"
    android:paddingLeft="5dp"
    android:id="@+id/article_title"
    android:layout_toRightOf="@+id/networkImage"/>

<com.android.volley.toolbox.NetworkImageView
    android:layout_width="130dp"
    android:id="@+id/networkImage"
    android:layout_height="120dp"
    />
 </RelativeLayout>

任何想法为什么会发生这种情况?

谢谢,

西奥。

【问题讨论】:

    标签: android xml layout android-recyclerview


    【解决方案1】:

    为您的TextView 添加属性android:layout_centerVertical="true",它应该垂直居中。

    【讨论】:

    • 是的。现在很好。如果我希望文本位于图像的右上角怎么办?
    • 我不确定我是否理解但现在不是图片右上角的文字吗?
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2011-06-26
    • 1970-01-01
    • 2021-01-03
    • 1970-01-01
    • 2021-05-06
    相关资源
    最近更新 更多