我有以下布局:
<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 允许项目相互“堆叠”,这正是您正在寻找的。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>
关于android - 如何将 ProgresBar 放在我的 ImageView 前面?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/17434600/