为内存使用创建仪表UI

时间:2015-01-16 05:52:12

标签: android android-layout android-activity

在我的Android应用程序中,我希望借助图形计量器(类似于Android设置中的计算器)向最终用户显示内存可用性

enter image description here

任何人都可以建议我可以用来开发这种UI的最佳UI组件。我用进度条尝试了几个样本,但它没有解决我的目的。

2 个答案:

答案 0 :(得分:1)

您可以使用一个线性布局,其中多个linearLayouts通过权重进行划分。

<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    android:orientation="horizontal" >

    <LinearLayout
        android:layout_width="match_parent"
        android:layout_height="50dp"
        android:background="#fff333"
        android:orientation="horizontal" >

        <LinearLayout
            android:layout_width="0dp"
            android:layout_height="match_parent"
            android:layout_weight="0.3"
            android:background="#fff333" >
        </LinearLayout>

        <LinearLayout
            android:layout_width="0dp"
            android:layout_height="match_parent"
            android:layout_weight="0.03"
            android:background="#80DAE4" >
        </LinearLayout>
        <LinearLayout
            android:layout_width="0dp"
            android:layout_height="match_parent"
            android:layout_weight="0.03"
            android:background="#80E487" >
        </LinearLayout>
        <LinearLayout
            android:layout_width="0dp"
            android:layout_height="match_parent"
            android:layout_weight="0.03"
            android:background="#80A3E4" >
        </LinearLayout>

        <LinearLayout
            android:layout_width="0dp"
            android:layout_height="match_parent"
            android:layout_weight="0.3"
            android:background="#E4B980" >
        </LinearLayout>
    </LinearLayout>

</LinearLayout>

答案 1 :(得分:0)

我认为你应该使用Android中可用的许多图形库中的一个(我不知道究竟是哪一个,但我确信存在一个用于此目的并且不记得名称)。是的,您可以创建这样的布局,但填充数据和更改宽度将是非常荒谬的。看看这些图书馆,看看你是否能找到合适的图书馆 Graphics libraries
William Chart

相关问题