android - 如何: Layout fixed size components with justified spacing

标签 android

当我有 1、2 或 3 个组件时,我知道如何让它们正确放置。但现在我有一个 View ,其中包含 4、5、... 组件。我不需要增加组件的尺寸(通过重量),而是需要它们保持固定的尺寸。那么...有什么方法可以以合理的间距(在 View 内均匀分布)来布局它们?

谢谢

J

最佳答案

我发现的一个类似的解决方法是添加间隔 View 组件。同样,这并不理想,但它确实有效。如果有更好的,请告诉我。

<LinearLayout
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:orientation="horizontal"
    >
    <biz.mycompany.mycomponent
        android:layout_width="@dimen/screen_view_w"
        android:layout_height="@dimen/screen_view_h"
        />
    <View
        android:layout_width="0px"
        android:layout_height="@dimen/main_screen_button_h"
        android:layout_weight="1"
        />
    <biz.mycompany.mycomponent2
        android:layout_width="@dimen/screen_view_w"
        android:layout_height="@dimen/screen_view_h"
        />
    <View
        android:layout_width="0px"
        android:layout_height="@dimen/screen_view_h"
        android:layout_weight="1"
        />
    <biz.mycompany.mycomponent3
        android:layout_width="@dimen/screen_view_w"
        android:layout_height="@dimen/screen_view_h"
        />
</LinearLayout>

关于android - 如何: Layout fixed size components with justified spacing,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/4400991/

相关文章:

android - React-native-router-flux 动态更新 rightButtonImage

Android APK 重新签名 :Certificate chain not validated

android - AsyncTask 中的可观察/订阅者

android - onFocusChange 代码示例?

android - Sony SmartWatch - 如何获取主机应用程序包名称

android - 如何在不转换为位图的情况下裁剪包含 Y'(亮度)的 byte[] 数组

android - Android SDK 中的 Rect 和 RectF

java - Firebase 数据库获取节点值

javascript - 在Android上运行NodeJS的可行选项(2017年8月)

java - 组织.json.JSONException : Unterminated string at character 1834