GridLayout未在设备上显示

时间:2018-01-11 14:56:52

标签: xamarin android-gridlayout

我在使用GridLayout时出现此问题,在两台三星设备上进行了测试。 这是布局的摘录:

    <GridLayout
        a:layout_width="0dp"
        a:layout_weight="2"
        a:layout_height="match_parent"
        a:rowCount="5"
        a:columnCount="4">
        <TextView
            a:id="@+id/tvDescentsFemaleCount"
            style="@style/dataPanelControlLabels"
            a:layout_width="0dp"
            a:layout_row="0"
            a:layout_column="0"
            a:layout_columnWeight="3"
            a:layout_columnSpan="3"
            a:text="@string/pnlVisitDescentsFemaleDescentNumber" />
        <Button
            a:id="@+id/bDescentsFemaleCount"
            style="@style/dataButton"
            a:layout_width="0dp"
            a:layout_row="1"
            a:layout_column="0"
            a:layout_columnWeight="3"
            a:layout_columnSpan="3"
            a:layout_marginLeft="3dp"
            a:layout_marginRight="3dp" />
        <ImageView
            a:id="@+id/ivDescentsMoveLeft"
            a:layout_width="0dp"
            a:layout_row="1"
            a:layout_column="3"
            a:layout_columnWeight="1"
            a:src="@drawable/freccia_indietro"
            a:adjustViewBounds="true"
            a:scaleType="centerInside" />
        <TextView
            a:id="@+id/tvDescentsMaleCount"
            style="@style/dataPanelControlLabels"
            a:layout_width="0dp"
            a:layout_row="2"
            a:layout_column="0"
            a:layout_columnSpan="3"
            a:layout_columnWeight="3"
            a:text="@string/pnlVisitDescentsMaleDescentNumber" />
        <Button
            a:id="@+id/bDescentsMaleCount"
            style="@style/dataButton"
            a:layout_width="0dp"
            a:layout_row="3"
            a:layout_column="0"
            a:layout_columnSpan="3"
            a:layout_columnWeight="3"
            a:layout_marginLeft="3dp"
            a:layout_marginRight="3dp" />
        <ImageView
            a:id="@+id/ivDescentsMoveRight"
            a:layout_width="0dp"
            a:layout_row="3"
            a:layout_column="3"
            a:layout_columnWeight="1"
            a:src="@drawable/freccia_avanti"
            a:adjustViewBounds="true"
            a:scaleType="centerInside" />
        <ImageView
            a:id="@+id/ivDescentsAdd"
            a:layout_width="0dp"
            a:layout_row="4"
            a:layout_column="0"
            a:layout_columnWeight="1"
            a:layout_margin="3dp"
            a:src="@drawable/add"
            a:adjustViewBounds="true"
            a:scaleType="centerInside"
            a:padding="6dp" />
        <ImageView
            a:id="@+id/ivDescentsRemove"
            a:layout_width="0dp"
            a:layout_height="wrap_content"
            a:layout_columnWeight="1"
            a:layout_row="4"
            a:layout_column="1"
            a:layout_margin="3dp"
            a:padding="6dp"
            a:src="@drawable/meno"
            a:adjustViewBounds="true"
            a:scaleType="centerInside" />
        <ToggleButton
            a:id="@+id/tbDescentsFemaleSelect"
            style="@style/toggleButtonPv"
            a:layout_width="0dp"
            a:layout_row="4"
            a:layout_column="2"
            a:layout_columnWeight="1"
            a:layout_height="wrap_content"
            a:layout_margin="3dp"
            a:textOn="@string/pnlVisitDescentsFemaleShort"
            a:textOff="@string/pnlVisitDescentsFemaleShort"
            a:padding="4dp" />
        <ToggleButton
            a:id="@+id/tbDescentsMaleSelect"
            style="@style/toggleButtonPv"
            a:layout_width="0dp"
            a:layout_row="4"
            a:layout_column="3"
            a:layout_columnWeight="1"
            a:layout_height="wrap_content"
            a:layout_margin="3dp"
            a:textOn="@string/pnlVisitDescentsMaleShort"
            a:textOff="@string/pnlVisitDescentsMaleShort"
            a:padding="4dp" />
    </GridLayout>

在完整的布局上有另一个GridLayout,唯一的区别是缺少a:layout_columnSpan属性(我已经将xmlns:android ...的经典命名空间声明缩短为xlmns:a ...)。 这是我的PC设计师不那么重要的截图: Screenshot from VS2017 designer

这是来自SM-T535,API级别21三星平板电脑的屏幕截图: SM-T535 screenshot 在左上角有一个GridLayout,在中间右边有一个android.support.v7.widget.GridLayout。我只留下了布局限制,以显示小部件的呈现方式。

这是SM-T585,API级别24三星平板电脑的屏幕截图: SM-T585 screenshot n. 1 GridLayout正确呈现,而右侧的android.support.v7.widget.GridLayout几乎以相同的方式呈现。

这是来自同一SM-T585的屏幕截图,其中所有两个小部件都是标准的GridLayout: enter image description here

请注意右侧GridLayout下的开关库;它们是android.support.v7.widget.SwitchCompat,因为最初我是在GT-N800三星平板电脑上移植应用程序,标准的Switch小部件不是那么可定制的。在活动代码中,我用标准字体替换资产中的字体。只有在SM-T585上才能正确显示字体。 活动继承自Activity,但从AppCompatActivity继承不会更改单个像素。 整个项目是一个Xamarin应用程序(我正在移植为IOS开发的相同应用程序,所以我要回收大部分代码),IDE是VS2017社区版。 相同的布局(GridLayout小部件)在Nexus 7上正常工作,尽管屏幕太小。 任何建议表示赞赏。 感谢。

鲁道夫。

0 个答案:

没有答案
相关问题