android - marginLeft 似乎不适用于我的 GridLayout

标签 android grid-layout

我正尝试在我的 Android 应用程序中使用 GridLayout,我希望它从屏幕左侧开始 160dp。当我设置 android:layout_marginLeft="160dp" 时,我在 Eclipse 的 GraphicalLayout 选项卡中看到了这种情况,但是当我构建应用程序时,它并没有反射(reflect)出该边距。

我错过了什么吗?

我的其余 GridLayout 代码:

<GridLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:id="@+id/GridLayout3"
    android:layout_width="wrap_content"
    android:layout_height="match_parent"
    android:layout_marginLeft="160dp"
    android:columnCount="4"
    android:orientation="horizontal" >

最佳答案

你在使用 http://developer.android.com/reference/android/view/LayoutInflater.html#inflate(int , android.view.ViewGroup) 膨胀布局?如果是这样,您是否提供了 Root View ?如果您传入 null,所有 layout_ 属性将从您的 GridLayout 中删除。

关于android - marginLeft 似乎不适用于我的 GridLayout,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/14652959/

相关文章:

android - 您建议客户使用 JSON 还是 XML?为什么?

android - Style.xml 文件未在 flutter 插件项目中读取?

android - 如何删除我:type ="d:string" from PropertyInfo of SOAP in KSOAP2 Android

css - PocketGrid:具有固定宽度导航列的网格布局

css - 如何在 Bootstrap 3 中制作此布局?

java - SAXParser 没有明确的原因为我提供了 62 个元素之后的第二个标签的空值,为什么?

android - 为 android/iOS 编译 c++

ios - 如何在IOS平台Nativescript中使用GridLayout codrrect

html - 嵌套网格中的最后一列总是在新行中

使用 GridLayout 的 Java 相册