gpt4 book ai didi

android - 如何调整 Android 中的 textview 位置? (字幕)

转载 作者:行者123 更新时间:2023-11-28 10:24:57 27 4
gpt4 key购买 nike

我正在使用 textview 为我的视频显示字幕,但无论我尝试什么,我都找不到稳定的位置。我无法将 TextView 放在屏幕底部。我想控制 TextView 的底部填充。很难解释,让我用截图来解释。也许这很容易,但我找不到解决方案。希望你能帮我。提前致谢。

这是我的 Xml

<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/MainView"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:orientation="vertical" >
<SurfaceView
android:id="@+id/SurfaceView"
android:layout_width="321dp"
android:layout_height="462dp"
android:layout_alignParentBottom="true"
android:layout_alignParentLeft="true"
android:layout_alignParentRight="true"
android:layout_alignParentTop="true" />
<TextView
android:id="@+id/textView1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentBottom="true"
android:layout_centerHorizontal="true"
android:gravity="center"
android:shadowColor="#000000"
android:shadowDx="4"
android:shadowDy="4"
android:shadowRadius="4"
android:text=""
android:textColor="#F2F2F2"
android:textSize="23px"
android:textStyle="bold" />
</RelativeLayout>

截图如下:

两行 TextView (我的屏幕) enter image description here

一行 TextView (我的屏幕) enter image description here

当它是两行时,这就是我想要的 enter image description here

当它是一行时,这就是我想要的 enter image description here

最佳答案

在视频帧顶部水平居中和垂直居中的一些 TextView 容器(例如 RelativeLayout),为容器设置水平和垂直边距,并将您的 TextView 放置到容器的底部,具有以下附加属性:

android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:gravity="center"

关于android - 如何调整 Android 中的 textview 位置? (字幕),我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/23769595/

27 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com