【发布时间】:2013-03-13 06:05:21
【问题描述】:
我正在构建一个计算器应用程序,并且我拥有所有按钮的图像。我还有一张我想用作计算器背景的图像。
这是我所拥有的一个简单示例:
按钮(所有单独的图像):
背景(单张图片):
期望的外观:
我将使用什么布局将图像网格(按钮)放置在单个图像之上。 GridLayout 优于 FrameLayout?
【问题讨论】:
我正在构建一个计算器应用程序,并且我拥有所有按钮的图像。我还有一张我想用作计算器背景的图像。
这是我所拥有的一个简单示例:
按钮(所有单独的图像):
背景(单张图片):
期望的外观:
我将使用什么布局将图像网格(按钮)放置在单个图像之上。 GridLayout 优于 FrameLayout?
【问题讨论】:
我会去
<LinearLayout android:background="..." android:orientation="vertical">
<LinearLayout android:orientation="horizontal">
<Button ... />
<Button ... />
<Button ... />
</LinearLayout><LinearLayout android:orientation="horizontal">
<Button ... />
<Button ... />
<Button ... />
</LinearLayout><LinearLayout android:orientation="horizontal">
<Button ... />
<Button ... />
<Button ... />
</LinearLayout><LinearLayout android:orientation="horizontal">
<Button ... />
<Button ... />
</LinearLayout>
</LinearLayout>
添加适当的android:layout_weight 值,您就完成了。
我不会使用GridLayout 或其他东西,因为您根本没有动态布局。一切都是静态的,永远不会改变......
【讨论】:
<FrameLayout android:background="....">
...
【讨论】: