0

I'm currently trying to place a progress bar on the top left corner of my screen. However, I'm not quite sure which way is the best way to do it. Should I create a progress bar programatically instead of creating it in the xml? Or should I change my layout around? Thanks. XML below.

XML CODE:

<?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>
Splitusa
  • 1,181
  • 7
  • 31
  • 51

4 Answers4

0

You can create it either way (In XML or Programatically). If you created it progamatcially, set the gravity to top and if you are creating in XML, use Relative Layout instead of Linear Layout and use android:layout_gravity="top|left". If you want to show it at the center follow the link

Community
  • 1
  • 1
ajaykoppisetty
  • 364
  • 4
  • 10
0

The best option for layout when you're wanting to position views in specific areas is FrameLayout or RelativeLayout

RelativeLayout will allow you to place each view relative to each other. FrameLayout allows you to stack views in a z-index positioning.

Play with both and you may come up with results you're looking for.

John Giotta
  • 16,432
  • 7
  • 52
  • 82
0

The best way to design layouts in android is by creating them in XML so you should do it in XML. You can achieve what you want by adding your ProgressBar before your ImageView

Cata
  • 11,133
  • 11
  • 65
  • 86
0

I doubt this is what you're looking for exactly, but another way you might want to implement a non-intrusive progress bar is to put it in the title bar of the activity. Check out this for an example of how to do this.

Community
  • 1
  • 1
Brian
  • 7,955
  • 16
  • 66
  • 107