Android Imageview上不可见的文本
我希望我的ImageView显示一条占位符消息:Android Imageview上不可见的文本,android,android-imageview,textview,Android,Android Imageview,Textview,我希望我的ImageView显示一条占位符消息:图像将显示在此处,一旦图像显示在该ImageView上,它就会消失 有人能给我提供解决方案吗?不确定您使用的是什么,因此我将介绍所有选项 1) 如果您只是在本地查看(没有internet) 只需制作一个与图像视图大小相同的图像,并使用paint或任何其他编辑器编写“图像将显示在此处” 或 这样做 <RelativeLayout> <TextView android:text = "the image will display
图像将显示在此处
,一旦图像显示在该ImageView上,它就会消失
有人能给我提供解决方案吗?不确定您使用的是什么,因此我将介绍所有选项 1) 如果您只是在本地查看(没有internet) 只需制作一个与图像视图大小相同的图像,并使用paint或任何其他编辑器编写“图像将显示在此处” 或 这样做
<RelativeLayout>
<TextView
android:text = "the image will display here"
android:id = "@+id/text"/>
<ImageView ..... android:id = "@+id/image"/>
</RelativeLayout>
将此文本视图的可见性设置为视图。加载图像时不可见
2) 如果你是从网上下载的
有一个名为piccasso(googleit)的库,你可以使用它,它具有所有的功能
在评论中询问更多问题,您可以使用FrameLayout或RelativeLayout。e、 g
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="wrap_content">
<ImageView
android:id="@+id/myImage"
android:layout_width="wrap_content"
android:layout_height="wrap_content""
android:src="@drawable/my_image"
android:contentDescription="@string/MY_IMAGE" />
<TextView
android:id="@+id/imageLoaderText"
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:layout_gravity="center"
android:layout_marginBottom="20dp"
android:layout_alignBottom="@+id/myImage"
android:layout_centerHorizontal="true"
android:text="@string/IMAGE_LOADING" />
</RelativeLayout>
加载图像时,图像仅显示在文本上并隐藏
<?xml version="1.0" encoding="utf-8"?>
<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent">
<TextView
android:id="@+id/textView"
android:gravity="center"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:text="TextView" />
<ImageView
android:id="@+id/imageView"
android:layout_gravity="center"
android:layout_width="100dp"
android:layout_height="100dp"
android:src="@mipmap/ic_launcher" />
</FrameLayout>
感谢…传统的方法是使用另一个视图(TextView
在您的案例中)替换为您案例中正在加载的任何视图(ImageView
)
我通常使用ViewSwitcher
来实现这一点。你能提供在ImageView上加载图像的代码吗?你可以有一个绘图表,上面写着这一点,然后一旦图像从web服务或任何你从中获取图像,就用加载的图像替换这个绘图表。谢谢你的回答。很高兴能帮上忙:),,请标出正确答案;汉克斯。它帮助了我
<RelativeLayout
... >
<ImageView
android:layout_width="match_parent"
android:layout_height="match_parent"
android:visibility="gone"
...
/>
<TextView
android:layout_width="match_parent"
android:layout_height="match_parent"
android:text="the image will display here"
...
/>
</RelativeLayout>
iv.setVisibility(View.VISIBLE);
tv.setVisibility(View.GONE);