如何在圆形ProgessBar内叠加imageView

时间:2018-11-12 18:05:39

标签: android android-layout

我有一个圆形的progressBar作为背景,一个为前景,并且我希望一个ImageView延伸到progressBar的整个内部。我该怎么做?

Layout.xml:

<?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:gravity="center"
android:id="@+id/voice_player_item"
android:layout_gravity="center"
android:orientation="vertical" >

<LinearLayout

    android:background="@drawable/layout_border"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:layout_marginLeft="10dp"
    android:layout_marginRight="10dp"

    android:orientation="vertical">

    <LinearLayout
        android:paddingTop="20dp"
        android:paddingBottom="20dp"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:layout_marginBottom="5dp"
        android:layout_marginLeft="7dp"

        android:layout_marginTop="5dp"
        android:orientation="horizontal">
        <ProgressBar
            android:id="@+id/voice_download_progress_background"
            style="?android:attr/progressBarStyleHorizontal"
            android:layout_width="50dp"
            android:layout_height="50dp"
            android:max="100"
            android:progress="100"
            android:progressDrawable="@drawable/circular_progressbar_background_download" />
        <ProgressBar
            android:layout_marginLeft="-50dp"
            android:id="@+id/voice_download_progress"
            style="?android:attr/progressBarStyleHorizontal"
            android:layout_width="50dp"
            android:layout_height="50dp"
            android:layout_centerInParent="true"
            android:indeterminate="false"
            android:max="100"
            android:progress="100"
            android:progressDrawable="@drawable/download_progress" />

        <ImageView
            android:id="@+id/download_play_icon"
            android:layout_width="46dp"
            android:layout_height="46dp"
            android:layout_marginLeft="-46dp"
            android:src="@drawable/download" />
        ....

circular_progressbar_background_download.xml(和)download_progress.xml(背景颜色不同):

<?xml version="1.0" encoding="utf-8"?>
<shape
xmlns:android="http://schemas.android.com/apk/res/android"
android:innerRadiusRatio="2.5"
android:shape="ring"
android:thickness="4dp"
android:useLevel="true">
<solid android:color="@color/topic_actionbar_background" />
</shape>

0 个答案:

没有答案