android - 如何将 ProgresBar 放在我的 ImageView 前面?

标签 android android-layout android-progressbar

我有以下布局:

<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。

请问我该如何实现?

这是期望的结果:

最佳答案

RelativeLayouts 允许项目相互“堆叠”,这正是您正在寻找的。

因此您可以将 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>

关于android - 如何将 ProgresBar 放在我的 ImageView 前面?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/17434600/

相关文章:

android - 如何在 Android 中更改进度条进度指示器颜色

android - 在android中创建矩形进度条

android - 是否可以在不显示键盘的情况下扩展 SearchView

java - 无法获取捕获的图像 uri

java - 带有文本的单选按钮中的缩放问题

android - 防止自定义 SurfaceView 在其他 View 之上绘制

android - 更改 AlertDialog 的标题标题

android - 如何在 Android 中开始 Activity 之前显示进度对话框?

java - 意外收到 NoClassDefFoundError

android - 软键盘隐藏工具栏