Android 精确视图定位

Android 精确视图定位,android,android-layout,android-activity,Android,Android Layout,Android Activity,在过去的一个小时里,我一直试图在我的活动的特定位置放置一个视图(确切地说是一个进度条),但没有成功。我的活动有一个背景图像,我需要将进度条与之对齐。以下是我需要的大致估计: *-----------------------* | | | 15% vertical | | | | XXXXX | | XXXXX | |

在过去的一个小时里,我一直试图在我的活动的特定位置放置一个
视图
(确切地说是一个
进度条
),但没有成功。我的活动有一个背景图像,我需要将进度条与之对齐。以下是我需要的大致估计:

*-----------------------*
|                       |
|       15% vertical    |
|                       |
|         XXXXX         |
|         XXXXX         |
|         XXXXX         |
|                       |
|                       |
|                       |
|                       |
|                       |
|                       |
|                       |
|                       |
|                       |
|                       |
*-----------------------*
我尝试过这些问题的解决方案(,),但我遗漏了一些东西。这是我到目前为止找到的最新清单:

<android.support.v4.widget.DrawerLayout xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:tools="http://schemas.android.com/tools"
    android:id="@+id/drawer_layout"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    tools:context=".MainActivity" >

    <LinearLayout
        android:id="@+id/pager"
        android:layout_width="fill_parent"
        android:layout_height="fill_parent"
        android:layout_margin="@dimen/activity_horizontal_margin"
        android:orientation="vertical" >

        <View
            android:layout_width="match_parent"
            android:layout_height="0dp"
            android:layout_weight="15" />

        <ProgressBar
            android:id="@+id/pbProgress"
            style="?android:attr/progressBarStyleLarge"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:indeterminate="true" />
    </LinearLayout>
</android.support.v4.widget.DrawerLayout>
有人能帮我对齐这个进度条吗


提前感谢

尝试将您的
ProgressBar
添加到带有权重的布局中

而不是

<ProgressBar
            android:id="@+id/pbProgress"
            style="?android:attr/progressBarStyleLarge"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:indeterminate="true" />

这样写:

*-----------------------*
|                       |
|    20~25% vertical    |
|                       |
|                       |
|                       |
|                       |
|XXXXX                  |
|XXXXX                  |
|XXXXX                  |
|                       |
|                       |
|                       |
|                       |
|                       |
|                       |
|                       |
*-----------------------*
<LinearLayout
  android:gravity="center_horizontal"
  android:layout_weight="85"
  android:layout_width="match_parent"
  android:layout_height="0dp">
   <ProgressBar
            android:id="@+id/pbProgress"
            style="?android:attr/progressBarStyleLarge"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:indeterminate="true" />
</LinearLayout>

更新:btw,而不是
fill\u parent
更好地使用
match\u parent