【问题标题】:How I can create this type of textured progress bar "line-diag" (ninepatch?)?如何创建这种类型的纹理进度条“line-diag”(ninepatch?)?
【发布时间】:2013-11-13 18:29:51
【问题描述】:

如何创建这种带纹理的进度条“line-diag”(ninepatch?)?

我已经阅读了一些帖子,我认为解决方案是使用 9-patch 类型的图像。但我不明白如何正确地做到这一点。你能解释一下如何制作这个进度条吗?

【问题讨论】:

  • 这里有什么进步?
  • 下图(红色)

标签: android android-layout android-custom-view android-progressbar


【解决方案1】:

我认为您不需要 9-patch。只需动态更改填充条的宽度(我猜那是鲜红色的),然后设置正确的scaleType.-

<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:tools="http://schemas.android.com/tools"
    android:layout_width="match_parent"
    android:layout_height="match_parent" >

    <ImageView
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:src="@drawable/bar_dark" />

    <ImageView
        android:layout_width="200dp"
        android:layout_height="wrap_content"
        android:scaleType="matrix"
        android:src="@drawable/bar_light" />

</RelativeLayout>


对于ProgressBar 组件,这篇文章可能会有所帮助。-

Android ProgressBar UI custom layout

【讨论】:

【解决方案2】:

不需要 9 补丁。您可以使用自定义 XML 可绘制对象。这是一个很好的教程:Android Tutorials for Beginners

Google“android 自定义进度条”获取更多示例。

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2020-01-10
    • 1970-01-01
    • 1970-01-01
    • 2021-10-15
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多