最近我看到一个应用程序,它有一个带有文本的图像。
应用程序是否使用ImageView
和TextView
?文字如何覆盖图像?它是如何完成的?
我附上了截图。
最近我看到一个应用程序,它有一个带有文本的图像。
应用程序是否使用ImageView
和TextView
?文字如何覆盖图像?它是如何完成的?
我附上了截图。
在布局中的 TextView 上设置属性 android:background="#00000000"。XML 文件。
<FrameLayout
android:layout_height="wrap_content"
android:layout_width="match_parent"
>
<ImageView
android:src="@drawable/your_image"
android:layout_height="match_parent"
android:layout_width="match_parent"
/>
<TextView
android:height="match_parent"
android:width="match_parent"
android:background="#00000000"
android:gravity="bottom"
/>
</FrameLayout>
您可以使用 FrameLayout 将 TextView 放在 ImageView 上,也可以使用带有背景资源的文本视图作为图像,例如:
<TextView
android:layout_gravity="center"
android:background="@drawable/custom_buttonclick"
android:gravity="center"
android:textSize="12dp"
android:textStyle="bold" />
通过使用相对布局、ImageView 和 TextView,您可以实现将 textView 的背景颜色透明化。