按钮和textview的android布局问题

时间:2011-09-11 12:17:25

标签: android android-layout relativelayout android-xml

我想根据下面的图片创建应用程序UI。请问有谁可以指导我如何实现这一目标?

enter image description here
Image Source

这里的数据像123 MB,456MB是动态的,并将不断改变应用程序本身。因此,理想情况下应该有2个按钮,在特定按钮内部,我们需要2个图像来显示上传/下载,并且需要2个textview来显示带宽计数。

但我无法想象这可以如何安排在一起?

此致 拉杰什

1 个答案:

答案 0 :(得分:0)

您可以使用多个嵌套LinearLayouts。像这样:

<LinearLayout android:orientation="horizontal"
    android:layout_height="wrap_content"
    android:layout_width="fill_parent">

    <TextView android:text="MOBILE" 
        android:layout_height="wrap_content"
        android:layout_width="0"
        android:layout_weight="0.25" />

    <LinearLayout android:orientation="vertical"
        android:layout_height="wrap_content"
        android:layout_width="0"
        android:layout_weight="0.25">

        <TextView android:text="123 MB"
            android:drawableLeft="@drawable/arrow_down" 
            android:layout_height="wrap_content"
            android:layout_width="fill_parent" />

        <TextView android:text="456 MB"
            android:drawableLeft="@drawable/arrow_up" 
            android:layout_height="wrap_content"
            android:layout_width="fill_parent" />

    </LinearLayout>

    <TextView android:text="WIFI" 
        android:layout_height="wrap_content"
        android:layout_width="0"
        android:layout_weight="0.25" />

    <LinearLayout android:orientation="vertical"
        android:layout_height="wrap_content"
        android:layout_width="0"
        android:layout_weight="0.25">

        <TextView android:text="123 MB"
            android:drawableLeft="@drawable/arrow_down" 
            android:layout_height="wrap_content"
            android:layout_width="fill_parent" />

        <TextView android:text="456 MB"
            android:drawableLeft="@drawable/arrow_up" 
            android:layout_height="wrap_content"
            android:layout_width="fill_parent" />

    </LinearLayout>


</LinearLayout>

编辑:任何LinearLayout都可以设置为clickableonClickListener可以注册任何操作。