【问题标题】:Which Layout(s) Should I Use? [closed]我应该使用哪种布局? [关闭]
【发布时间】:2013-03-13 06:05:21
【问题描述】:

我正在构建一个计算器应用程序,并且我拥有所有按钮的图像。我还有一张我想用作计算器背景的图像。

这是我所拥有的一个简单示例:

按钮(所有单独的图像):

背景(单张图片):

期望的外观:

我将使用什么布局将图像网格(按钮)放置在单个图像之上。 GridLayout 优于 FrameLayout?

【问题讨论】:

    标签: android layout grid frame


    【解决方案1】:

    我会去

    <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 或其他东西,因为您根本没有动态布局。一切都是静态的,永远不会改变......

    【讨论】:

      【解决方案2】:
      <FrameLayout android:background="....">
      

      ...

      【讨论】:

      • 啊,我看到你添加了背景属性。谢谢!
      • aha :) 我编辑了它!再次检查@JanTacci
      • FrameLayout中一般可以堆叠多个项目。
      猜你喜欢
      • 2017-03-30
      • 1970-01-01
      • 2012-01-25
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2015-08-12
      • 2011-06-14
      相关资源
      最近更新 更多