使用四个ImageButton创建布局/屏幕(全部大小相同)

时间:2015-04-23 22:40:08

标签: android android-layout height imagebutton

创建一个只包含四个ImageButtons的Android版面我遇到了很大的问题。

应该如下所示: https://cldn0.fiverrcdn.com/fiverr/t_main1/gigs/3008268/original/minimal-trend_0.jpg

目前我创建了一个带有两个LinearLayout的TableLayout(水平:每个包含两个按钮。)但我这样做是通过设置确切的值:

<ImageButton
            android:layout_width="178dp"
            android:layout_height="260dp"
            android:src="@drawable/personal_coach"
            android:id="@+id/button_personal_coach"
            android:layout_weight="0.25"
            android:scaleType="fitXY"
            android:background="?android:selectableItemBackground"
            android:layout_marginRight="4dp"
            />

有更好的方法吗? (更动态地用于其他屏幕尺寸,而不将宽度和高度设置为值)

1 个答案:

答案 0 :(得分:3)

尝试类似:

update t
set scott = CONCAT(
           (select scott
            from tablename
            where id = t.id - 1),
            scott)
from tablename t
where Scott not like '%0%'
and Scott not like '%1%'
and Scott not like '%2%'
and Scott not like '%3%'
and Scott not like '%4%'
and Scott not like '%5%'
and Scott not like '%6%'
and Scott not like '%7%'
and Scott not like '%8%'
and Scott not like '%9%'

<强>解释

这里我们使用weight属性,它根据重量按百分比划分屏幕。例如,在两个孩子中放置1,这将使他们占据屏幕的50%。这就是我们在垂直方向上首先做的事情,然后是每个按钮的水平方式。