如何在 ImageView 中实现重叠的 TextView,它结合起来用作 Button?
How to implement a overlapping TextView in a ImageView, which combinely works as a Button?
我是 Android 开发的新手,我需要知道是否可以将 imageView 和 TextView 重叠到一个按钮中。它应该与我共享的图像类似,我需要将它框在一个有 2 列的 GridLayout 中。如果我为每个 imageView 和 textView 使用 FrameLayout 它变得有点复杂,有没有其他方法?
试试这个 运行...如果出现任何错误请告诉我,我会提供帮助
<?xml version="1.0" encoding="utf-8"?>
<GridLayout
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:layout_width="wrap_content"
android:layout_height="wrap_content">
<Button
android:id="@+id/img_category"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:background="@drawable/your_image"
android:scaleType="centerCrop"
android:textColor="@color/colorBlack"
android:text="Title"
android:textSize="25sp"/>
</GridLayout>
我是 Android 开发的新手,我需要知道是否可以将 imageView 和 TextView 重叠到一个按钮中。它应该与我共享的图像类似,我需要将它框在一个有 2 列的 GridLayout 中。如果我为每个 imageView 和 textView 使用 FrameLayout 它变得有点复杂,有没有其他方法?
试试这个 运行...如果出现任何错误请告诉我,我会提供帮助
<?xml version="1.0" encoding="utf-8"?>
<GridLayout
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:layout_width="wrap_content"
android:layout_height="wrap_content">
<Button
android:id="@+id/img_category"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:background="@drawable/your_image"
android:scaleType="centerCrop"
android:textColor="@color/colorBlack"
android:text="Title"
android:textSize="25sp"/>
</GridLayout>