2015-04-26 23 views
1

我试图在我的活动中实现ProgressBar,但进度条很大(cf截图)。 enter image description here 编辑我的布局中的宽度或高度属性不会改变事情。FrameLayout中的ProgressBar方式太大

这是我目前使用的代码。

<android.support.v4.widget.DrawerLayout xmlns:android="http://schemas.android.com/apk/res/android" 
    android:id="@+id/drawer_layout" 
    android:layout_width="match_parent" 
    android:layout_height="match_parent" 
    > 
<FrameLayout 
    android:id="@+id/content_frame" 
    android:layout_width="match_parent" 
    android:padding="10dp" 
    android:layout_height="match_parent" /> 

<ProgressBar 
    android:id="@+id/main_progressBar" 

    android:layout_width="wrap_content" 
    android:layout_height="wrap_content" 
    /> 

<ListView 
    android:id="@+id/left_drawer" 
    android:layout_width="240dp" 
    android:layout_height="match_parent" 
    android:layout_gravity="start" 
    android:background="#111" 
    android:choiceMode="singleChoice" 
    android:dividerHeight="0dp" /> 

</android.support.v4.widget.DrawerLayout> 

您有任何提示吗?

在此先感谢。

回答

4

试试这个

<android.support.v4.widget.DrawerLayout xmlns:android="http://schemas.android.com/apk/res/android" 
    android:id="@+id/drawer_layout" 
    android:layout_width="match_parent" 
    android:layout_height="match_parent" 
    > 
    <FrameLayout 
     android:id="@+id/content_frame" 
     android:layout_width="match_parent" 
     android:padding="10dp" 
     android:layout_height="match_parent" /> 

    <RelativeLayout 
     android:layout_width="fill_parent" 
     android:layout_height="fill_parent"> 

     <ProgressBar 
      android:id="@+id/main_progressBar" 
      android:layout_width="wrap_content" 
      android:layout_height="wrap_content" 
      android:layout_centerInParent="true" /> 
    </RelativeLayout> 

    <ListView 
     android:id="@+id/left_drawer" 
     android:layout_width="240dp" 
     android:layout_height="match_parent" 
     android:layout_gravity="start" 
     android:background="#111" 
     android:choiceMode="singleChoice" 
     android:dividerHeight="0dp" /> 

</android.support.v4.widget.DrawerLayout> 
+0

看到我的编辑.... –

+0

工作就像一个魅力,非常感谢! – Vico

+1

这就是RelativeLayout的秘密;) –

0

您是否有意为FrameLayout添加结束标记?

我想你想要这个布局。

<FrameLayout 
     android:id="@+id/content_frame" 
     android:layout_width="match_parent" 
     android:padding="10dp" 
     android:layout_height="match_parent"> 

     <ProgressBar 
      android:id="@+id/main_progressBar"  
      android:layout_width="wrap_content" 
      android:layout_height="wrap_content"/> 

     <ListView 
      android:id="@+id/left_drawer" 
      android:layout_width="240dp" 
      android:layout_height="match_parent" 
      android:layout_gravity="start" 
      android:background="#111" 
      android:choiceMode="singleChoice" 
      android:dividerHeight="0dp" /> 
    </FrameLayout 
+0

根据该文档,FrameLayout里不应该包含别的: https://developer.android.com/training/implementing-navigation/nav-drawer.html 编辑:没有看到,但我的代码不满。我修复了我的帖子。 – Vico

+0

我使用的FrameLayout必须布局里面它大多重叠,以便我可以轻松地显示/隐藏组控件。常见的用法是不要放任何东西,以便您可以将它用作容器,但也可以这样使用它。 –