【问题标题】:How to put a ProgresBar in front of my ImageView?如何在我的 ImageView 前面放置一个 ProgresBar?
【发布时间】:2013-07-02 19:51:36
【问题描述】:

我有以下布局:

<LinearLayout
    android:id="@+id/main_ui_container"
    android:layout_width="fill_parent"
    android:layout_height="fill_parent"
    android:background="@color/red"
    android:orientation="vertical" >

    <com.facebook.widget.LoginButton
        android:id="@+id/login_button"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_marginTop="5dp"
        facebook:confirm_logout="false"
        facebook:fetch_user_info="true" />

    <ImageView
        android:id="@+id/imageView1"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:layout_weight="0.26"
        android:src="@drawable/logo" />


</LinearLayout>

我想在 ImageView 的前面(或顶部,取决于你如何看待它)放置一个 ProgresBar。

请问我该如何实现?

这是想要的结果:

【问题讨论】:

  • 使用RelativeLayout而不是LinearLayout...
  • @Frohnzie 请问我该怎么做?

标签: android android-layout android-progressbar


【解决方案1】:

RelativeLayouts 允许项目“堆叠”在彼此之上,这正是您要寻找的。​​p>

因此,您可以将 LinearLayout 包装在 RelativeLayout 中,并将 ProgressBar 添加到 RelativeLayout,如下所示:

<RelativeLayout
    android:layout_width="match_parent"
    android:layout_height="match_parent" />

    <LinearLayout
        android:id="@+id/main_ui_container"
        android:layout_width="fill_parent"
        android:layout_height="fill_parent"
        android:layout_alignParentLeft="true"
        android:layout_alignParentTop="true"
        android:background="@color/red"
        android:orientation="vertical" >

        <!-- Primary content -->

    </LinearLayout>

    <ProgressBar
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:layout_alignParentLeft="true"
        android:layout_alignParentTop="true" />

</RelativeLayout>

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多