我想在android中将按钮(子视图)带到前面

时间:2013-11-20 13:39:28

标签: android android-layout

    <?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/topHeader"
      android:layout_width="wrap_content"
      android:layout_height="wrap_content" >


      <!-- Header aligned to top -->
    <!--   <include layout="@layout/header_layout" /> -->

      <!-- Footer aligned to bottom -->
    <!--   <include layout="@layout/footer_layout" /> -->

      <!-- Content below header and above footer -->
    <!--   <include layout="@layout/intermediate_layout" /> -->
      <RelativeLayout
        android:layout_width="fill_parent"
        android:layout_height="fill_parent"
        android:gravity="center">

        <ImageView
        android:id="@+id/imgLogo"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_centerInParent="true"
        android:src="@drawable/header" />
      </RelativeLayout>

    </RelativeLayout>

我制作布局xml,其中我将一个按钮放在中心。我希望该按钮始终在前面。         我在这个布局上动态添加了一些textview,imageview等,并且应该将一个中心按钮带到前面。         这在ios中是可能的,我想在android.Any建议这个想法?     我有topHeaderlayout.xml 在这个xml中,我动态添加了视图。一个按钮应该在视图的前面。

2 个答案:

答案 0 :(得分:13)

您可以使用 bringToFront 方法(http://developer.android.com/reference/android/view/View.html)。另请阅读此内容 - Defining Z order of views of RelativeLayout in Android。我认为这应该有所帮助。

答案 1 :(得分:3)

总结并澄清:

yourView.bringToFront();
相关问题