有 Java 编程相关的问题?

你可以在下面搜索框中键入要查询的问题!

java Android在imageview中放置多个位图

我有多个图像视图,它们都是透明的,彼此重叠。然后我将彼此对齐,但有一个问题摆在面前。如何设置它们的分层顺序?我试着在xml中修改代码,以及在实际java代码中如何设置图像

我尝试过FrameLayout,但可能我没有正确使用它。。。以下是我的实现:

<FrameLayout xmlns:安卓="http://schemas.安卓.com/apk/res/安卓"
xmlns:tools="http://schemas.安卓.com/tools"
安卓:layout_width="fill_parent"
安卓:layout_height="fill_parent"
tools:context=".RadarActivity" >

    <ImageView
        安卓:id="@+id/imageview_topo"
        安卓:layout_width="wrap_content"
        安卓:layout_height="wrap_content"
        安卓:layout_marginTop="45dp"
        安卓:scaleType="center"
        安卓:visibility="invisible" />

     <ImageView
        安卓:id="@+id/imageview_counties"
        安卓:layout_width="wrap_content"
        安卓:layout_height="wrap_content"
        安卓:layout_marginTop="45dp"
        安卓:scaleType="center"
        安卓:visibility="invisible" />

不管我做什么。。。imageview_topo始终位于顶部。即使在代码中,我也先实例化了topo,并首先检索了它的图像

谢谢!


共 (1) 个答案

  1. # 1 楼答案

    我提到了一个网站here,上面写着:

    If multiple child views exist, then they are drawn, in order, one atop the other. This means that the first view added to the frame layout will display on the bottom of the stack, and the last view added will display on top.

    你也可以查看这个网站:http://blog.neteril.org/blog/2013/10/10/framelayout-your-best-ui-friend/

    如果你展示你的用户界面截图,也许我能帮你更多