平面按钮,listview android

时间:2014-07-28 14:42:07

标签: android listview button

我很难指出这里使用的UI元素是什么?它是按钮还是列表视图?

enter image description here

2 个答案:

答案 0 :(得分:0)

此视图似乎不是列表视图。它们是按钮或ImageButton安装在一些布局中。

答案 1 :(得分:0)

如果你想在ListView中制作它,你将会遇到困难。最好的方法是在GridLayout中创建它,如果你不自信地使用它,那么最简单的解决方案是在垂直方向的根中LinearLayout,然后添加LinearLayout孩子们有'weight =“1”

的水平方向

这样的东西(仅适用于前两个按钮):

<LinearLayout
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:orientation="vertical" >

    <LinearLayout
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:layout_weight="1"
        android:layout_marginLeft="10dp"
        android:layout_marginRight="10dp"
        android:layout_marginTop="20dp">

        <FrameLayout
            android:layout_width="0dp"
            android:layout_height="50dp"
            android:layout_weight="1"
            android:clickable="true"
            android:layout_marginRight="10dp"
            android:onClick="onChildOneClick">

            <TextView
                android:layout_width="match_parent"
                android:layout_height="match_parent"
                android:text="Button 1"
                android:background="android:color/green" />

        </FrameLayout>

        <FrameLayout
            android:layout_width="0dp"
            android:layout_height="50dp"
            android:layout_weight="1"
            android:clickable="true"
            android:layout_marginLeft="10dp"
            android:onClick="onChildTwoClick" />
    </LinearLayout>

</LinearLayout>

在你的framelayout中,你可以放置ImageView + TextView使其看起来像草图

相关问题