【问题标题】:Align long text at the right and bottom of the imageview android在imageview android的右侧和底部对齐长文本
【发布时间】:2021-09-18 13:01:18
【问题描述】:

我的android 应用程序中有一个activity,我想在其中显示完整的博客。博客有两件事,即图像和描述,后者有时会变得很长,具体取决于用户写的内容。图像和描述都来自服务器。现在我想像附图一样设计我的活动,我不知道这是否可以从xmljava 完成。

我尝试在我的activity 中使用RelativeLayout,如下所示,但它没有覆盖ImageView 下方的空间。

<?xml version="1.0" encoding="utf-8"?>
<ScrollView xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:app="http://schemas.android.com/apk/res-auto"
    xmlns:tools="http://schemas.android.com/tools"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:layout_margin="10dp"
    tools:context=".PostDetailsActivity">

    <RelativeLayout
        android:layout_width="match_parent"
        android:layout_height="wrap_content">

        <ImageView
            android:id="@+id/postImg"
            android:layout_width="200dp"
            android:layout_height="200dp"
            android:src="@drawable/logo" />

        <TextView
            android:layout_toRightOf="@id/postImg"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:text="@string/test" />

    </RelativeLayout>

</ScrollView>

【问题讨论】:

    标签: java android xml


    【解决方案1】:

    在图片中,您有 2 个文本框。在布局中,您只有 1 个。这怎么可能起作用? Android 视图是矩形的。您不能以随机方式塑造它们或以随机方式塑造文本。

    你的标题是错误的。你是说:

    在imageview android的右下角对齐长文本

    但实际上应该是:

    “如何在 TextView 中以随机形状对齐文本。”

    尝试用 2 个 TextView 找出新设计。查看第一个 TextView 中可以容纳的内容,并将其余文本放在另一个 TextView 中。也许你可以让它们看起来只有一个。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2012-04-06
      • 1970-01-01
      • 2017-04-27
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多