Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/android/183.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/0/docker/9.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Android ImageView中是否有层的概念?_Android_Android Imageview - Fatal编程技术网

Android ImageView中是否有层的概念?

Android ImageView中是否有层的概念?,android,android-imageview,Android,Android Imageview,我正在实现一个ImageView,它具有以下效果:背景是从url加载的图像,图像上有文本。文本后面还有一个阴影。也就是说,ImageView上有三层。ImageView中是否有层的概念可以使渲染更容易?是的,只是将不同的层映射到不同的布局容器中 很简单: <RelativeLayout> <--Layer one--> <RelativeLayout> <--Layer two>

我正在实现一个ImageView,它具有以下效果:背景是从url加载的图像,图像上有文本。文本后面还有一个阴影。也就是说,ImageView上有三层。ImageView中是否有层的概念可以使渲染更容易?

是的,只是将不同的层映射到不同的布局容器中

很简单:

<RelativeLayout>

    <--Layer one-->
          <RelativeLayout>
               <--Layer two>

                        <RelativeLayout>
                             <--Layer three-->
                        </RelativeLayout/>


          <RelativeLayout/>


    <RelativeLayout/>

这是你的答案

<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:orientation="vertical" >

   <!--  FOR SHADOW EFFECT -->
    <ImageView 
        android:layout_width="fill_parent"
        android:layout_height="fill_parent"
        />
    <!--  FOR IMAGE FROM URL -->
    <ImageView 
        android:layout_width="fill_parent"
        android:layout_height="fill_parent"
        />
    <!--  FOR TEXT OVER IMAGE  -->
     <TextView 
        android:layout_width="fill_parent"
        android:layout_height="fill_parent"
        />
</RelativeLayout>

不在ImageView中。当然,您可以将ImageView子类化并重写onDraw()方法,以便在位图顶部的画布中绘制其他内容。但是你最好按照FrameLayout或者@Nun'eChai建议的RelativeLayout使用普通布局。