Android 是否在自定义视图中使用进度条?

Android 是否在自定义视图中使用进度条?,android,progress-bar,draw,android-custom-view,Android,Progress Bar,Draw,Android Custom View,您好,我已经创建了一个自定义视图和一个lifebarprocess.xml。我想在我的自定义视图中绘制救生艇以及我绘制的所有其他东西。但我不知道如何: -在我的视图中创建/引用processbar以及如何绘制它。 -可以更改progressbar xml吗 自定义视图(短路): lifeprocessbar.xml: <layer-list xmlns:android="http://schemas.android.com/apk/res/android" > <item

您好,我已经创建了一个自定义视图和一个lifebarprocess.xml。我想在我的自定义视图中绘制救生艇以及我绘制的所有其他东西。但我不知道如何:

-在我的视图中创建/引用processbar以及如何绘制它。 -可以更改progressbar xml吗

自定义视图(短路):

lifeprocessbar.xml:

<layer-list xmlns:android="http://schemas.android.com/apk/res/android" >
  <item android:id="@android:id/background">
    <shape>
      <corners android:radius="5dip" />
      <gradient
        android:angle="270"
        android:centerColor="#ff5a5d5a"
        android:centerY="0.5"
        android:endColor="#ff747674"
        android:startColor="#ff9d9e9d" />
    </shape>
  </item>
  <item android:id="@android:id/progress">
    <clip>
      <shape>
        <corners android:radius="5dip" />
          <gradient
            android:angle="0"
            android:endColor="#ff0000"
            android:startColor="#ff3300" />
      </shape>
    </clip>
  </item>
</layer-list>

还有lifebarprocess_布局:

<?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:orientation="vertical" >


        <ProgressBar
        android:id="@+id/playerlifeprocessbar"
        style="?android:attr/progressBarStyleHorizontal"
        android:layout_width="fill_parent"
        android:layout_height="wrap_content"
        android:layout_alignParentLeft="true"
        android:layout_marginTop="30dp"
        android:progress="90"
        android:progressDrawable="@drawable/lifeprocessbar" />


</LinearLayout>


我的朋友可以帮忙,谢谢你

> P>您可能需要考虑扩展到<代码> GAMECONTROLLRIEVIEW 而不是视图。从文件中:

视图组是一种特殊视图,可以包含其他视图(称为 视图组是布局和视图的基类 容器

<?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:orientation="vertical" >


        <ProgressBar
        android:id="@+id/playerlifeprocessbar"
        style="?android:attr/progressBarStyleHorizontal"
        android:layout_width="fill_parent"
        android:layout_height="wrap_content"
        android:layout_alignParentLeft="true"
        android:layout_marginTop="30dp"
        android:progress="90"
        android:progressDrawable="@drawable/lifeprocessbar" />


</LinearLayout>