【问题标题】:Android - How to have an grid with 3 images (height 33%, width 100%)Android - 如何拥有一个包含 3 个图像的网格(高度 33%,宽度 100%)
【发布时间】:2015-01-07 07:50:03
【问题描述】:

我是 android 开发的初学者,如果我的问题需要解决,非常抱歉。我试图在互联网上搜索,但没有什么好用的。

我试图创建一个像这样的视图:

我可以使用 RelativeLayout 或至少使用 GridView 成功吗? 最好的祝福, Zed13

【问题讨论】:

    标签: android height width imagebutton


    【解决方案1】:

    使用带有 weightsum 3 的 Linearlayout 并放置三个高度为 1 的视图,这就是您想要的视图。如下所示,而不是按钮使用您想要的视图、布局等,它们完全分开。

      <?xml version="1.0" encoding="utf-8"?>
    <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:background="#fff"
        android:orientation="vertical"
        android:weightSum="3" >
    
        <Button
            android:layout_width="match_parent"
            android:layout_height="0dp"
            android:layout_weight="1"
            android:background="#f7f0db" />
    
        <Button
            android:layout_width="match_parent"
            android:layout_height="0dp"
            android:layout_weight="1"
            android:background="#17f0db" />
    
        <Button
            android:layout_width="match_parent"
            android:layout_height="0dp"
            android:layout_weight="1"
            android:background="#89f1db" />
    
    </LinearLayout>
    

    【讨论】:

    • 非常感谢,非常完美:)
    猜你喜欢
    • 2011-01-09
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2020-08-11
    • 1970-01-01
    • 1970-01-01
    • 2014-01-23
    • 1970-01-01
    相关资源
    最近更新 更多