我想在 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>
请看上面的截图,帮我更新我的 XML
这样 TextView
就会出现在 ImageView
之后。
最佳答案
替换FrameLayout
与 LinearLayout
或 RelativeLayout
因为 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/