Android ProgressBar .xml布局

tcd*_*tcd 4 eclipse android android-progressbar progress-bar

我有一个XML文件:

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="fill_parent"
    android:layout_height="fill_parent"
    android:orientation="vertical" >

    <ProgressBar
        android:id="@+id/progressbar"
        style="?android:attr/progressBarStyleLarge"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_gravity="center_vertical|center_horizontal"
        android:visibility="visible" />

    <WebView
        android:id="@+id/web_engine"
        android:layout_width="fill_parent"
        android:layout_height="fill_parent"
        android:visibility="gone" />

</LinearLayout>
Run Code Online (Sandbox Code Playgroud)

而我要的ProgressBarLarge风格,并在屏幕的中间垂直和水平居中......当我设置layout_widthheightfill_parent,它增加了实际负荷微调到整个屏幕的大小...我怎样才能让布局适合整个屏幕并居中实际加载图标?

Mic*_*hal 10

我已经检查了几种可能性,根据我的经验,这项任务的最佳选择是:

<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="fill_parent"
    android:layout_height="fill_parent" >

    <ProgressBar
        android:id="@+id/progressbar"
        style="?android:attr/progressBarStyleLarge"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_centerInParent="true"
        android:visibility="visible" />

    <WebView
        android:id="@+id/web_engine"
        android:layout_width="fill_parent"
        android:layout_height="fill_parent"
        android:layout_alignParentLeft="true"
        android:layout_alignParentTop="true"       
        android:visibility="gone" />

</RelativeLayout>
Run Code Online (Sandbox Code Playgroud)

我使用RelativeLayoutandroid:layout_centerInParent="true"该作品比更好LinearLayout.

干杯