自定义进度条:无法在屏幕中心找到它

时间:2015-07-21 17:01:13

标签: android android-progressbar

我正在努力实现我自己的进度条,问题是它没有填满屏幕,而且点数非常小。我想要做的是这样的事:enter image description here

但我得到的是:enter image description here

如果我的进度条在纵向方向水平填充屏幕,我该怎么办?并在横向方向垂直填充?另外我想在圆圈之间留一些空间我该怎么做?

这是我的cutomprogressbar.xml代码:

EDITED

  <LinearLayout
    android:id="@+id/RelativeLayout01"
    xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:orientation="horizontal"
    android:layout_gravity="center"
   >

        <ImageView
            android:id="@+id/imgOne"
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:contentDescription="@string/des"
            android:src="@drawable/gray"
            android:tag="1" />
        <ImageView 
           android:id="@+id/imgTwo" 
           android:layout_width="match_parent"
           android:layout_height="wrap_content"

           android:contentDescription="@string/des"
           android:src="@drawable/gray"
           android:tag="2"
            />
        <ImageView 
           android:id="@+id/imgThree" 
           android:layout_width="match_parent"
           android:layout_height="wrap_content"

           android:contentDescription="@string/des"
           android:src="@drawable/gray"
           android:tag="3"
            />
        <ImageView 
           android:id="@+id/imgFour" 
           android:layout_width="match_parent"
           android:layout_height="wrap_content"

           android:contentDescription="@string/des"
           android:src="@drawable/gray"
           android:tag="4"
            />
        <ImageView 
           android:id="@+id/imgFive" 
           android:layout_width="match_parent"
           android:layout_height="wrap_content"

           android:contentDescription="@string/des"
           android:src="@drawable/gray"
           android:tag="5"
            />
        <ImageView 
           android:id="@+id/imgSix" 
           android:layout_width="match_parent"
           android:layout_height="wrap_content"

           android:contentDescription="@string/des"
           android:src="@drawable/gray"
           android:tag="6"
            />
        <ImageView 
           android:id="@+id/imgSeven" 
           android:layout_width="match_parent"
           android:layout_height="wrap_content"

           android:contentDescription="@string/des"
           android:src="@drawable/gray"
           android:tag="7"
            />
        <ImageView 
           android:id="@+id/imgEight" 
           android:layout_width="match_parent"
           android:layout_height="wrap_content"

           android:contentDescription="@string/des"
           android:src="@drawable/gray"
           android:tag="8"
            />
        <ImageView 
           android:id="@+id/imgNine" 
           android:layout_width="match_parent"
           android:layout_height="wrap_content"


           android:contentDescription="@string/des"
           android:src="@drawable/gray"
           android:tag="9"
            />
        <ImageView 
           android:id="@+id/imgTen" 
           android:layout_width="match_parent"

           android:layout_height="wrap_content"

           android:contentDescription="@string/des"
           android:src="@drawable/gray"
           android:tag="10"
            />
        </LinearLayout>

1 个答案:

答案 0 :(得分:0)

首先,我将在这种情况下使用线性布局。在纵向资源文件中设置android:orientation="Horizontal"和&#34;垂直&#34;在横向资源文件中(/ res / layout中需要两个文件,/ res / layout-land中需要第二个文件)

修改 尝试进行以下更改: -

<LinearLayout
        android:layout_height="wrap_content"
        android:layout_width="match_parent"
        android:orientation="horizontal"
        android:gravity="center"
        <Img1
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:padding="4dp"
            />
        <Img2
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:padding="4dp"
            />
       <Img3
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:padding="4dp"
            />
        <Img4
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:padding="4dp"
            />
        <Img5
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:padding="4dp"
            />
        <Img6
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:padding="4dp"
            />
        <Img7
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:padding="4dp"
            />
        <Img8
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:padding="4dp"
            />
        <Img9
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:padding="4dp"
            />
        <Img10
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:padding="4dp"
            />
/>

分享您的结果。