Android 如何在“PhotoView”上显示文本?

Android 如何在“PhotoView”上显示文本?,android,android-linearlayout,android-imageview,android-photoview,Android,Android Linearlayout,Android Imageview,Android Photoview,在我的应用程序中,我使用名为PhotoView的库全屏显示图像(这实际上是一个新活动)。下面是示例图像,所以我需要像那样显示文本 我已经发布了XML代码: <?xml version="1.0" encoding="utf-8"?> <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" xmlns:tools="http://schemas.android.com/tools"

在我的应用程序中,我使用名为
PhotoView
的库全屏显示图像(这实际上是一个新活动)。下面是示例图像,所以我需要像那样显示文本

我已经发布了XML代码:

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:tools="http://schemas.android.com/tools"
    android:id="@+id/activity_view_full_screen_image"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:paddingBottom="@dimen/activity_vertical_margin"
    android:paddingLeft="@dimen/activity_horizontal_margin"
    android:paddingRight="@dimen/activity_horizontal_margin"
    android:paddingTop="@dimen/activity_vertical_margin"
    tools:context="com.example.theace.fullscreen.ViewFullScreenImage"
    android:orientation="vertical">

        <LinearLayout
            android:id="@+id/li1"
            android:layout_width="match_parent"
            android:layout_height="match_parent"
            android:orientation="vertical">

                <com.github.chrisbanes.photoview.PhotoView
                    android:id="@+id/photo_view"
                    android:layout_width="match_parent"
                    android:layout_centerInParent="true"
                    android:layout_height="match_parent"
                    android:layout_marginBottom="40dp" />

                <TextView
                    android:layout_width="match_parent"
                    android:layout_height="30dp"
                    android:layout_marginBottom="10dp"
                    android:textColor="@android:color/white"
                    android:id="@+id/tv1"/>


        </LinearLayout>


</LinearLayout>

如何修复此问题?

尝试此操作,使您的活动\u视图\u全屏.xml如下所示

使用
RelativeLayout
并将您的
TextView
设置为
android:layout\u alignParentBottom=“true”


只需使用下面的代码

<?xml version="1.0" encoding="utf-8"?>
<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:tools="http://schemas.android.com/tools"
    android:id="@+id/activity_view_full_screen_image"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    tools:context="com.example.theace.fullscreen.ViewFullScreenImage"
    android:orientation="vertical">


        <com.github.chrisbanes.photoview.PhotoView
            android:id="@+id/photo_view"
            android:layout_width="match_parent"
            android:layout_centerInParent="true"
            android:layout_height="match_parent"
            android:scaleType="center"/>

        <TextView
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:layout_marginBottom="10dp"
            android:layout_alignParentBottom="true"
            android:textColor="@android:color/white"
            android:layout_gravity="bottom|center_horizontal"
            android:id="@+id/tv1"/>


</FrameLayout>


对不起,这不是解决办法。您正在图像下方显示文本,使图像无论在什么情况下都显示在文本上方。我还尝试添加一个50字的长文本,大部分文本都不可见。文本应该在图像底部的顶部(如果图像足够大),你不明白吗?文本应该像我提供的屏幕截图一样。请检查,文本不在图像下方,而是在图像的底部。截图取自WhatsApp。在那里,如果图像“不够大”不能全屏显示,文本将在黑色背景中显示在图像的正下方,否则它将显示屏幕截图中的文本。关于这个问题的否决票和关闭票,所以“方法”是告诉你为什么否决票或关闭票,而不仅仅是点击按钮然后运行。我认为没有理由投反对票或反对票。所以我们真的需要调查小组来调查这些“肇事逃逸”的人。@PeakGen:你被误报了。这样一来,人们可以出于任何他们喜欢的原因投票,他们可以匿名投票,只要他们不关注一个用户。许多在元堆栈溢出时改变这一点的建议都失败了。
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:id="@+id/activity_view_full_screen_image"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical">


<com.github.chrisbanes.photoview.PhotoView
    android:id="@+id/photo_view"
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    android:layout_centerInParent="true"
    android:scaleType="fitXY"
    android:layout_marginBottom="40dp"
    android:src="@drawable/disha" />



    <TextView
        android:id="@+id/tv1"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:layout_marginBottom="10dp"
        android:gravity="center"
        android:padding="5dp"
        android:layout_alignParentBottom="true"
        android:background="#9a080808"
        android:text="@string/abc"
        android:textColor="@android:color/white" />


</RelativeLayout>
<?xml version="1.0" encoding="utf-8"?>
<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:tools="http://schemas.android.com/tools"
    android:id="@+id/activity_view_full_screen_image"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    tools:context="com.example.theace.fullscreen.ViewFullScreenImage"
    android:orientation="vertical">


        <com.github.chrisbanes.photoview.PhotoView
            android:id="@+id/photo_view"
            android:layout_width="match_parent"
            android:layout_centerInParent="true"
            android:layout_height="match_parent"
            android:scaleType="center"/>

        <TextView
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:layout_marginBottom="10dp"
            android:layout_alignParentBottom="true"
            android:textColor="@android:color/white"
            android:layout_gravity="bottom|center_horizontal"
            android:id="@+id/tv1"/>


</FrameLayout>