嵌套的textview在设备上不可见,但在设计模式下可见

时间:2018-09-16 01:50:21

标签: android-layout android-studio android-studio-3.1.4

应用程序顶部组件在TableLayout下具有4个TableRows,每个组件都有一个嵌套的TextView和一个Switch。 所有这些都设置为Visibility:visible 并且在NexusS(4.0,480x800,hdpi)的所有可用分辨率下,它们在设计模式下均按预期显示 但是当在分辨率和大小相同的棉花糖设备上启动时,只有开关显示在正确的位置,这四个文本视图消失了。.

http://i.stack.imgur.com/xmPqk.png

({http://i.stack.imgur.com/6UNBo.png)![on设备]

这里有相关的xml

<?xml version="1.0" encoding="utf-8"?>
<android.support.constraint.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:app="http://schemas.android.com/apk/res-auto"
    xmlns:tools="http://schemas.android.com/tools"
    android:id="@+id/MainPage"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:background="@drawable/bb"
    android:hapticFeedbackEnabled="false"
    android:minHeight="320dp"
    android:minWidth="240dp"
    android:visibility="visible"
    tools:context=".MainActivity">

    <Button
        android:id="@+id/play"
        android:layout_width="120dp"
        android:layout_height="34dp"
        android:layout_marginBottom="188dp"
        android:layout_marginEnd="205dp"
        android:layout_marginStart="24dp"
        android:background="#ad000000"
        android:hapticFeedbackEnabled="false"
        android:text="@string/playBtn"
        android:textAllCaps="true"
        android:textColor="@android:color/white"
        android:textStyle="bold"
        android:typeface="monospace"
        android:visibility="visible"
        app:layout_constraintBottom_toBottomOf="parent"
        app:layout_constraintEnd_toEndOf="parent"
        app:layout_constraintHorizontal_bias="0.272"
        app:layout_constraintStart_toStartOf="parent" />

    <Button
        android:id="@+id/settings"
        android:layout_width="120dp"
        android:layout_height="38dp"
        android:layout_marginTop="8dp"
        android:background="#ad000000"
        android:hapticFeedbackEnabled="false"
        android:text="@string/setBtn"
        android:textAllCaps="true"
        android:textColor="@android:color/white"
        android:textStyle="bold"
        android:typeface="monospace"
        android:visibility="visible"
        app:layout_constraintStart_toStartOf="@+id/play"
        app:layout_constraintTop_toBottomOf="@+id/play" />

    <Button
        android:id="@+id/quit"
        android:layout_width="120dp"
        android:layout_height="38dp"
        android:layout_marginTop="8dp"
        android:background="#ad000000"
        android:hapticFeedbackEnabled="false"
        android:text="@string/quitBtn"
        android:textAllCaps="true"
        android:textColor="@android:color/white"
        android:textStyle="bold"
        android:typeface="monospace"
        android:visibility="visible"
        app:layout_constraintStart_toStartOf="@+id/settings"
        app:layout_constraintTop_toBottomOf="@+id/settings" />

    <TextView
        android:id="@+id/Title"
        android:layout_width="wrap_content"
        android:layout_height="178dp"
        android:layout_marginBottom="20dp"
        android:layout_marginTop="20dp"
        android:fontFamily="@font/owaw"
        android:textColor="@android:color/white"
        android:textSize="120sp"
        android:visibility="visible"
        app:layout_constraintBottom_toTopOf="@+id/play"
        app:layout_constraintEnd_toEndOf="parent"
        app:layout_constraintTop_toTopOf="parent"
        app:layout_constraintVertical_bias="0.418"
        tools:text="@string/app_name" />

    <TableLayout
        android:id="@+id/OptionsLayout"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:background="@android:color/black"
        android:gravity="center_vertical|start"
        android:orientation="vertical"
        android:paddingEnd="0dp"
        android:paddingStart="100dp"
        android:visibility="visible"
        app:layout_constraintBottom_toBottomOf="parent"
        app:layout_constraintEnd_toEndOf="parent"
        app:layout_constraintHorizontal_bias="0.0"
        app:layout_constraintStart_toStartOf="parent"
        app:layout_constraintTop_toBottomOf="@+id/Title"
        app:layout_constraintVertical_bias="0.0">

        <TableRow
            android:id="@+id/Option1"
            android:layout_width="wrap_content"
            android:layout_height="match_parent"
            android:layout_marginTop="24dp"
            android:orientation="horizontal"
            android:visibility="visible"
            app:layout_constraintBottom_toTopOf="@+id/Option2"
            app:layout_constraintEnd_toEndOf="@+id/Option2"
            app:layout_constraintHorizontal_bias="0.5"
            app:layout_constraintStart_toStartOf="@+id/Option2"
            app:layout_constraintTop_toTopOf="parent">

            <TextView
                android:layout_width="150dp"
                android:layout_height="wrap_content"
                android:paddingBottom="20dp"
                android:textAppearance="@style/TextAppearance.AppCompat.Button"
                android:textColor="@android:color/white"
                android:textSize="20sp"
                android:textStyle="bold"
                android:visibility="visible"
                tools:text="@string/opt1" />

            <Switch
                android:id="@+id/tutorialSwitch"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:layout_margin="0dp"
                android:allowUndo="true"
                android:alpha="0.8"
                android:background="@android:color/black"
                android:checked="true"
                android:hapticFeedbackEnabled="false"
                android:padding="0dp"
                android:showText="false"
                android:splitTrack="false"
                android:switchMinWidth="20dp" />
        </TableRow>

        <TableRow
            android:id="@+id/Option2"
            android:layout_width="wrap_content"
            android:layout_height="match_parent"
            android:orientation="horizontal"
            android:visibility="visible"
            app:layout_constraintBottom_toTopOf="@+id/Option3"
            app:layout_constraintEnd_toEndOf="@+id/Option3"
            app:layout_constraintHorizontal_bias="0.5"
            app:layout_constraintStart_toStartOf="@+id/Option3"
            app:layout_constraintTop_toBottomOf="@+id/Option1">

            <TextView
                android:layout_width="150dp"
                android:layout_height="wrap_content"
                android:paddingBottom="20dp"
                android:textAppearance="@style/TextAppearance.AppCompat.Button"
                android:textColor="@android:color/white"
                android:textSize="20sp"
                android:textStyle="bold"
                android:visibility="visible"
                tools:text="@string/opt2" />

            <Switch
                android:id="@+id/musicSwitch"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:layout_margin="0dp"
                android:layout_marginEnd="-70dp"
                android:allowUndo="true"
                android:alpha="0.8"
                android:background="@android:color/black"
                android:checked="true"
                android:hapticFeedbackEnabled="false"
                android:padding="0dp"
                android:showText="false"
                android:splitTrack="false"
                android:switchMinWidth="20dp" />
        </TableRow>

        <TableRow
            android:id="@+id/Option3"
            android:layout_width="wrap_content"
            android:layout_height="match_parent"
            android:orientation="horizontal"
            android:visibility="visible"
            app:layout_constraintBottom_toTopOf="@+id/Option4"
            app:layout_constraintEnd_toEndOf="@+id/Option4"
            app:layout_constraintHorizontal_bias="0.5"
            app:layout_constraintStart_toStartOf="@+id/Option4"
            app:layout_constraintTop_toBottomOf="@+id/Option2">

            <TextView
                android:layout_width="150dp"
                android:layout_height="wrap_content"
                android:paddingBottom="20dp"
                android:textAppearance="@style/TextAppearance.AppCompat.Button"
                android:textColor="@android:color/white"
                android:textSize="20sp"
                android:textStyle="bold"
                android:visibility="visible"
                tools:text="@string/opt3" />

            <Switch
                android:id="@+id/hapticSwitch"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:layout_margin="0dp"
                android:allowUndo="true"
                android:alpha="0.8"
                android:background="@android:color/black"
                android:checked="false"
                android:hapticFeedbackEnabled="false"
                android:padding="0dp"
                android:showText="false"
                android:splitTrack="false"
                android:switchMinWidth="20dp" />
        </TableRow>

        <TableRow
            android:id="@+id/Option4"
            android:layout_width="wrap_content"
            android:layout_height="match_parent"
            android:orientation="horizontal"
            android:visibility="visible"
            app:layout_constraintBottom_toTopOf="@+id/Option5"
            app:layout_constraintEnd_toEndOf="@+id/Option5"
            app:layout_constraintHorizontal_bias="0.5"
            app:layout_constraintStart_toStartOf="@+id/Option5"
            app:layout_constraintTop_toBottomOf="@+id/Option3">

            <TextView
                android:layout_width="150dp"
                android:layout_height="wrap_content"
                android:paddingBottom="20dp"
                android:textAppearance="@style/TextAppearance.AppCompat.Button"
                android:textColor="@android:color/white"
                android:textSize="20sp"
                android:textStyle="bold"
                android:visibility="visible"
                tools:text="@string/opt4" />

            <Switch
                android:id="@+id/sfxSwitch"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:layout_margin="0dp"
                android:allowUndo="true"
                android:alpha="0.8"
                android:background="@android:color/black"
                android:checked="true"
                android:hapticFeedbackEnabled="true"
                android:padding="0dp"
                android:showText="false"
                android:splitTrack="false"
                android:switchMinWidth="20dp" />
        </TableRow>

        <TableRow
            android:id="@+id/Option5"
            android:layout_width="match_parent"
            android:layout_height="match_parent"
            android:gravity="center"
            android:orientation="horizontal"
            android:visibility="visible"
            app:layout_constraintBottom_toBottomOf="parent"
            app:layout_constraintStart_toStartOf="parent"
            app:layout_constraintTop_toBottomOf="@+id/Option4">

            <TextView
                android:id="@+id/saveOption"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:layout_marginEnd="60dp"
                android:layout_marginTop="20dp"
                android:clickable="true"
                android:focusable="true"
                android:hapticFeedbackEnabled="false"
                android:paddingBottom="20dp"
                android:textAppearance="@style/TextAppearance.AppCompat.Button"
                android:textColor="@android:color/white"
                android:textSize="20sp"
                android:textStyle="bold"
                android:visibility="visible"
                tools:text="@string/opt5" />
        </TableRow>
    </TableLayout>

</android.support.constraint.ConstraintLayout>

更新: 我向每个字体家族添​​加了字体家族属性,现在文本在设备上可见,但是我不明白它的重要性,因为那里已经有了默认选项。

0 个答案:

没有答案