【发布时间】:2017-11-25 21:18:59
【问题描述】:
切换元素顺序时,将Button放在ImageButton之后,z-index不受影响。我尝试使用其他类型的视图,它们根据它们在父级FrameLayout 中的顺序正确放置在另一个之上。
我以编程方式尝试使用 View.bringToFront() 没有成功。
<FrameLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content">
<Button
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Suzi"
android:textSize="22sp" />
<ImageButton
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:src="@mipmap/ic_launcher" />
</FrameLayout>
【问题讨论】:
-
在
FrameLayout中放置两个按钮有什么意义? -
按钮没有ID,怎么调用bringToFront()?贴出代码
-
重点是将一个 Button 放在一边,有一些偏移,但在另一个之上。
-
我尝试bringToFront() 他们有ID,这里的重点是我认为他们应该在框架中改变顺序时改变堆栈位置
-
发布代码,没有它我们可以帮助你......也许你以错误的方式使用了 BringToFront() 或其他什么,现在我们只能相信你的话