2011-12-08 76 views
0

我正在尝试在屏幕的左上角放置进度条。但是,我不太确定哪种方式是最好的方法。我应该以编程方式创建一个进度条,而不是在xml中创建它?或者我应该改变我的布局?谢谢。下面的XML。Android - 在左上角显示进度条

XML代码:布局,当你想在特定区域定位的观点是FrameLayoutRelativeLayout

RelativeLayout将让你每个视图相对放置彼此

<?xml version="1.0" encoding="utf-8"?> 
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" 
    android:layout_width="match_parent" 
    android:layout_height="match_parent" 
    android:background="@drawable/background" 
    android:focusableInTouchMode="true" 
    android:orientation="vertical" > 

    <ImageView 
     android:id="@+id/imageView1" 
     android:layout_width="fill_parent" 
     android:layout_height="53dp" 
     android:layout_marginBottom="5dp" 
     android:src="@raw/topbar" /> 

    <TextView 
     android:id="@+id/search_nameOfFeed" 
     android:layout_width="match_parent" 
     android:layout_height="wrap_content" 
     android:gravity="center_vertical|center_horizontal" 
     android:text="Event Name" 
     android:textColor="@color/black" 
     android:textSize="18sp" > 
    </TextView> 

    <ListView 
     android:id="@+id/searchfeed_view" 
     android:layout_width="fill_parent" 
     android:layout_height="fill_parent" 
     android:layout_weight="0.83" 
     android:dividerHeight="10.0sp" 
     android:fadingEdge="none" 
     android:stackFromBottom="false" 
     android:transcriptMode="normal" > 
    </ListView> 

</LinearLayout> 

回答

0

最好的选择。 FrameLayout允许您在z-index定位中堆叠视图。

与你一起玩,你可能会想出你正在寻找的结果。

0

在android中设计布局的最好方法是通过在XML中创建它们,所以您应该使用XML。你可以达到你想要的东西通过添加ProgressBar之前,您ImageView

0

我怀疑这是你在寻找什么,但另一种方式你可能想实现一个非侵入式的进度条来把它的标题活动的酒吧。查看this,了解如何执行此操作的示例。

0

您可以通过任意方式创建它(以XML或编程方式)。如果您创建它,请将重力设置为最高,如果使用XML创建,请使用相对布局而不是线性布局,并使用android:layout_gravity =“top | left”。如果你想在中心显示它follow the link