Android-在左上角显示进度条
我目前正试图在屏幕的左上角放置一个进度条。然而,我不太确定哪种方法是最好的方法。我是否应该以编程方式创建进度条,而不是在xml中创建进度条?或者我应该改变我的布局吗?谢谢下面是XML XML代码:Android-在左上角显示进度条,android,layout,view,progress-bar,Android,Layout,View,Progress Bar,我目前正试图在屏幕的左上角放置一个进度条。然而,我不太确定哪种方法是最好的方法。我是否应该以编程方式创建进度条,而不是在xml中创建进度条?或者我应该改变我的布局吗?谢谢下面是XML XML代码: <?xml version="1.0" encoding="utf-8"?> <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="matc
<?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>
当您想要在特定区域定位视图时,布局的最佳选项是
框架布局
或相对布局
RelativeLayout
将允许您相对放置每个视图。
FrameLayout
允许您以z索引位置堆叠视图
在android中设计布局的最佳方法是使用XML创建布局,因此您应该使用XML。您可以通过在
ImageView
之前添加ProgressBar
来实现所需的功能。我怀疑这正是您想要的,但您可能希望实现非侵入式进度条的另一种方法是将其放在活动的标题栏中。查看如何执行此操作的示例。您可以通过任何一种方式(以XML或编程方式)创建它。如果以编程方式创建,请将重力设置为top;如果以XML创建,请使用相对布局而不是线性布局,并使用android:layou_gravity=“top | left”。如果你想在中心展示它