Android半圆形进度条-绘制半圆

2024-04-22

我用这个创建了一个半圆形进度条devadvance\circularSeekBar https://github.com/devadvance/circularseekbar当我从调色板中选择自定义视图时,它看起来像这样。

progress bar in palette.

在此我有两个带有权重的相对布局。包含进度条的布局的权重为 2,底部布局的权重为 3。并且进度条的布局宽度和高度设置为换行内容。

所以我的问题是为什么从调色板中选择进度条时看起来像这样?画布尺寸是否采用完美的正方形?我想要的是半圆形进度条被这样的布局完全包围。

对此的任何说明都值得赞赏。

EDITxml代码

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:tools="http://schemas.android.com/tools"
    android:id="@+id/main_parent_view"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:orientation="vertical"
    android:fitsSystemWindows="true">

    <include layout="@layout/toolbar"/>

    <android.support.v4.widget.DrawerLayout
        android:id="@+id/drawer_layout"
        android:layout_width="match_parent"
        android:layout_height="0dp"
        android:layout_weight="3">

        <LinearLayout
            android:id="@+id/content_frame"
            android:layout_width="match_parent"
            android:layout_height="match_parent"
            android:orientation="vertical">

            <RelativeLayout xmlns:app = "http://schemas.android.com/apk/res-auto"
                android:id ="@+id/calorie_frame"
                android:layout_width="match_parent"
                android:layout_height="match_parent"
                android:layout_weight="2"
                android:clickable="true">
                <com.devadvance.circularseekbar.CircularSeekBar
                    android:id="@+id/calorie_progressbar"
                    android:layout_width="wrap_content"
                    android:layout_height="wrap_content"
                    app:start_angle = "180"
                    app:end_angle = "0"
                    app:progress = "25"
                    app:circle_x_radius="200"
                    app:circle_y_radius="200"
                    app:circle_stroke_width = "30"
                    app:use_custom_radii="true"
                    app:circle_color ="#FFFACD"

                    android:layout_alignParentEnd="false"
                    android:layout_alignParentStart="false"
                    android:layout_centerInParent="true" />
                </RelativeLayout>

            <RelativeLayout
                android:id="@+id/exercise_frame"
                android:layout_width="match_parent"
                android:layout_height="match_parent"
                android:layout_weight="3"
                android:clickable="true">

                <TextView
                    android:layout_width="wrap_content"
                    android:layout_height="wrap_content"
                    android:textAppearance="?android:attr/textAppearanceMedium"
                    android:text="@string/calorie_label"
                    android:id="@+id/textView"
                    android:layout_marginBottom="40dp"
                    android:layout_alignParentBottom="true"
                    android:layout_alignParentRight="true"
                    android:layout_alignParentEnd="true"
                    android:layout_marginRight="20dp" />

                <ImageView
                    android:layout_width="wrap_content"
                    android:layout_height="wrap_content"
                    android:id="@+id/imageView"
                    android:layout_alignBottom="@+id/textView"
                    android:layout_alignParentLeft="true"
                    android:layout_alignParentStart="true"
                    android:layout_marginLeft="50dp"
                    android:layout_marginStart="50dp"
                    android:contentDescription="@string/exercise_image" />

            </RelativeLayout>
        </LinearLayout>

        <ListView
            android:id="@+id/left_drawer"
            android:layout_width="240dp"
            android:layout_height="match_parent"
            android:layout_gravity="start"
            android:choiceMode="singleChoice"
            android:divider="@android:color/transparent"
            android:dividerHeight="0dp"
            android:background="#999"/>
    </android.support.v4.widget.DrawerLayout>

</LinearLayout>

add this

android:layout_height="0dp"

而不是这个

android:layout_height="match_parent" 

对于您添加权重属性的相对布局。

for

android:id="@+id/exercise_frame"   
android:id ="@+id/calorie_frame"

ID 更改高度=“0dp”

希望它有效...

本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)

Android半圆形进度条-绘制半圆 的相关文章

随机推荐