android - 在 ImageView 之后显示 TextView

标签 android android-layout textview imageview

我想在 ImageView 之后显示 TextView,但现在在我的 Android 屏幕上,Text 覆盖了 Image。

布局:

<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
tools:context="in.sitemakers.sitemakers.AboutFragment">

<ImageView
    android:id="@+id/about_image"
    android:src="@drawable/sitemakers_laptops"
    android:layout_width="match_parent"
    android:scaleType="fitXY"
    android:layout_height="420dp" />

<TextView
    android:layout_below="@+id/about_image"
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    android:text="Site Makers is the web development company engage in the.."
    />

</FrameLayout>

Preview

请看上面的截图,帮我更新我的 XML 这样 TextView 就会出现在 ImageView 之后。

最佳答案

替换FrameLayoutLinearLayoutRelativeLayout因为 FrameLayout 将一个 View 放在另一个 View 之上

LinearLayout:以线性方式放置 subview ,水平或垂直一个接一个。

注意:线性布局还允许您根据指定的 weight 属性值在 subview 之间动态分配可用的宽度和高度。

相对布局: 一种布局,其中子级的位置可以相对于彼此或父级进行描述

还有很多其他ViewGroups you can use按照说明

注意: 不要使用 px 而是使用 dp 作为 android:layout_height="420dp" 因为px 代表实际屏幕像素,限制在大屏幕上保持相同大小的 View ( View 将非常小),如此处 Density independence 所述

关于android - 在 ImageView 之后显示 TextView,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/46990561/

相关文章:

android - Unity Android IL2CPP 构建成功但未生成Apk

android - 双击编辑文本时出现非法状态异常

android - 如何在更改seekbar android时更改textview的颜色?

android - 从自定义 ListView 中的 TextView -w/Button 获取文本

android - 如何在Android map 上叠加png图片并指定四个 anchor

android - 从 Button onClick 获取 TextView 的值并通过 TextWatcher 将值传递给 TextView

android - 如何在点击编辑文本时播放声音

java - Android:测验应用程序中的随机 Activity

android - 找不到 support-v4.aar (com.android.support :support-v4:26. 1.0)

android - 得到异常 : fragment already active