Android TextView更改字体大小在父级布局中创建了神秘的上边距

时间:2018-08-29 19:27:32

标签: xamarin xamarin.android textview margins

我正在尝试在xamarin android中创建一个简单的针垫视图。我正在使用网格视图。每个按钮都是一个RelativeLayout,上面有一个浮动操作按钮和文本视图。一切都集中在父级中。

我面临的问题是,当我在某些文本视图上更改字体大小时,在该特定按钮上添加了一个神秘的上边距。

我尝试使用...

                android:autoText="false"
                android:lineSpacingMultiplier="0"
                android:lineSpacingExtra="0dp"
                android:includeFontPadding="false"

无分辨率。

这到底是怎么回事?

此处所有文本均为20dp大小。

enter image description here

现在这里是20dp的数字和14dp的单词。

enter image description here

<RelativeLayout
    android:layout_below="@id/SalesInformationLayout"
    android:id="@+id/KeypadGridLayout"
    android:layout_height="match_parent"
    android:layout_width="match_parent"
    android:layout_above="@id/SalesBottomToolbar">
    <GridLayout
        android:rowCount="4"
        android:columnCount="4"
        android:minWidth="25px"
        android:minHeight="25px"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_centerInParent="true">
        <RelativeLayout
            android:layout_row="0"
            android:layout_column="0"
            android:layout_height="wrap_content"
            android:layout_width="wrap_content">
            <Refractored.Fab.FloatingActionButton
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                fab:fab_colorNormal="@color/causePendingOrange"
                fab:fab_colorPressed="@color/causePendingOrange"
                fab:fab_colorRipple="@color/causePendingOrange"
                android:background="@color/causePendingOrange"
                android:id="@+id/Keypad1Button"
                android:layout_centerInParent="true" />
            <TextView
                android:lineSpacingExtra="0dp"
                android:includeFontPadding="false"
                android:elevation="20dp"
                fontPath="fonts/MPLUSRoundedRegular.ttf"
                android:text="7"
                android:layout_height="wrap_content"
                android:layout_width="wrap_content"
                android:textColor="@android:color/white"
                android:textSize="20dp"
                android:layout_centerInParent="true" />
        </RelativeLayout>
        <RelativeLayout
            android:layout_row="0"
            android:layout_column="1"
            android:layout_height="wrap_content"
            android:layout_width="wrap_content">
            <Refractored.Fab.FloatingActionButton
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                fab:fab_colorNormal="@color/causePendingOrange"
                fab:fab_colorPressed="@color/causePendingOrange"
                fab:fab_colorRipple="@color/causePendingOrange"
                android:background="@color/causePendingOrange"
                android:id="@+id/Keypad2Button" />
            <TextView
                android:lineSpacingExtra="0dp"
                android:textSize="20dp"
                android:includeFontPadding="false"
                android:elevation="20dp"
                fontPath="fonts/MPLUSRoundedRegular.ttf"
                android:layout_height="wrap_content"
                android:layout_width="wrap_content"
                android:textColor="@android:color/white"
                android:text="8"
                android:layout_centerInParent="true" />
        </RelativeLayout>
        <RelativeLayout
            android:layout_row="0"
            android:layout_column="2"
            android:layout_height="wrap_content"
            android:layout_width="wrap_content">
            <Refractored.Fab.FloatingActionButton
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                fab:fab_colorNormal="@color/causePendingOrange"
                fab:fab_colorPressed="@color/causePendingOrange"
                fab:fab_colorRipple="@color/causePendingOrange"
                android:background="@color/causePendingOrange"
                android:id="@+id/Keypad3Button" />
            <TextView
                android:autoText="false"
                android:lineSpacingMultiplier="0"
                android:lineSpacingExtra="0dp"
                android:includeFontPadding="false"
                android:textSize="20dp"
                android:elevation="20dp"
                fontPath="fonts/MPLUSRoundedRegular.ttf"
                android:layout_height="wrap_content"
                android:layout_width="wrap_content"
                android:textColor="@android:color/white"
                android:text="9"
                android:layout_centerInParent="true" />
        </RelativeLayout>
        <RelativeLayout
            android:layout_row="0"
            android:layout_column="3"
            android:layout_height="wrap_content"
            android:layout_width="wrap_content">
            <Refractored.Fab.FloatingActionButton
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                fab:fab_colorNormal="@color/causePendingOrange"
                fab:fab_colorPressed="@color/causePendingOrange"
                fab:fab_colorRipple="@color/causePendingOrange"
                android:background="@color/causePendingOrange"
                android:id="@+id/Keypad4Button" />
            <TextView
                android:autoText="false"
                android:lineSpacingMultiplier="0"
                android:lineSpacingExtra="0dp"
                android:includeFontPadding="false"
                android:textSize="20dp"
                android:elevation="20dp"
                fontPath="fonts/MPLUSRoundedRegular.ttf"
                android:text="CLEAR"
                android:layout_height="wrap_content"
                android:layout_width="wrap_content"
                android:textColor="@android:color/white"
                android:layout_centerInParent="true" />
        </RelativeLayout>
        <RelativeLayout
            android:layout_row="1"
            android:layout_column="0"
            android:layout_height="wrap_content"
            android:layout_width="wrap_content">
            <Refractored.Fab.FloatingActionButton
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                fab:fab_colorNormal="@color/causePendingOrange"
                fab:fab_colorPressed="@color/causePendingOrange"
                fab:fab_colorRipple="@color/causePendingOrange"
                android:background="@color/causePendingOrange" />
            <TextView
                android:textSize="20dp"
                android:elevation="20dp"
                fontPath="fonts/MPLUSRoundedRegular.ttf"
                android:text="4"
                android:layout_height="wrap_content"
                android:layout_width="wrap_content"
                android:textColor="@android:color/white"
                android:layout_centerInParent="true" />
        </RelativeLayout>
        <RelativeLayout
            android:layout_row="1"
            android:layout_column="1"
            android:layout_height="wrap_content"
            android:layout_width="wrap_content">
            <Refractored.Fab.FloatingActionButton
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                fab:fab_colorNormal="@color/causePendingOrange"
                fab:fab_colorPressed="@color/causePendingOrange"
                fab:fab_colorRipple="@color/causePendingOrange"
                android:background="@color/causePendingOrange" />
            <TextView
                android:layout_centerInParent="true"
                android:textSize="20dp"
                android:elevation="20dp"
                fontPath="fonts/MPLUSRoundedRegular.ttf"
                android:text="5"
                android:layout_height="wrap_content"
                android:layout_width="wrap_content"
                android:textColor="@android:color/white" />
        </RelativeLayout>
        <RelativeLayout
            android:layout_row="1"
            android:layout_column="2"
            android:layout_height="wrap_content"
            android:layout_width="wrap_content">
            <Refractored.Fab.FloatingActionButton
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                fab:fab_colorNormal="@color/causePendingOrange"
                fab:fab_colorPressed="@color/causePendingOrange"
                fab:fab_colorRipple="@color/causePendingOrange"
                android:background="@color/causePendingOrange" />
            <TextView
                android:layout_centerInParent="true"
                android:textSize="20dp"
                android:elevation="20dp"
                fontPath="fonts/MPLUSRoundedRegular.ttf"
                android:text="6"
                android:layout_height="wrap_content"
                android:layout_width="wrap_content"
                android:textColor="@android:color/white" />
        </RelativeLayout>
        <RelativeLayout
            android:layout_row="1"
            android:layout_column="3"
            android:layout_height="wrap_content"
            android:layout_width="wrap_content">
            <Refractored.Fab.FloatingActionButton
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                fab:fab_colorNormal="@color/causePendingOrange"
                fab:fab_colorPressed="@color/causePendingOrange"
                fab:fab_colorRipple="@color/causePendingOrange"
                android:background="@color/causePendingOrange" />
            <TextView
                android:layout_centerInParent="true"
                android:textSize="20dp"
                android:elevation="20dp"
                fontPath="fonts/MPLUSRoundedRegular.ttf"
                android:text="SCAN"
                android:layout_height="wrap_content"
                android:layout_width="wrap_content"
                android:textColor="@android:color/white" />
        </RelativeLayout>
    </GridLayout
</RelativeLayout>

0 个答案:

没有答案