@Leos Literak: Приятно слышать, что это помогает вам решить вашу проблему! Будем рады услышать от вас

юLinearLayout сTextView, GridLayout и другойTextView, Он отображается правильно на многих современных телефонах и планшетах, но на маленьком дисплее, например Nexus S., он не работает. См. Следующие рисунки.

Я пытался уменьшить размер шрифта, удалить фон из 9-ти патчей и даже убрать все поля. Я мог видеть только цифру 7, когда были некоторые поля. Затем я свернул их и вижу четыре строки с первой кнопкой, которая отображается в два раза больше экрана. Я не понимаю, почему, это должно иметьwrap_content ширина.

Я попытался минимизировать код и сократил его доGridLayout с одной строкой, и он все еще не соответствует ширине экрана.

Что там происходит?

Обновить:

420x800 точек на дюйм работает420x800 HDPI сломан540x920 hdpi работает720x1280 hdpi работает

Обновление 2:

Nexus 5x имеет те же проблемы, когда шрифт 38sp или больше. Интересно, что дизайнер Studio показывает правильную компоновку, но и устройство / эмулятор показывает поврежденное представление и следующую ошибку:

D/android.support.v7.widget.GridLayout: vertical constraints: y1-y0>=197, y2-y1>=197, y3-y2>=197, y4-y3>=197, y4-y0<=785 are inconsistent; permanently removing: y4-y0<=785. 

calc.xml:

<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical">

<!--Display row-->
<TextView
    android:id="@+id/assignment"
    android:text="50 + 40 = 90"
    style="@style/Formula"
    android:focusable="false"
    android:layout_width="match_parent"
    android:layout_height="80dp"
    tools:ignore="HardcodedText" />

<android.support.v7.widget.GridLayout
    android:layout_width="match_parent"
    android:layout_height="0dp"
    android:layout_weight="1"
    app:columnCount="4"
    app:rowCount="4">

    <!-- row with 7-9,+ -->

    <Button
        android:id="@+id/digit7"
        android:text="7"
        style="@style/KeypadLeftButton"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_weight="1"
        app:layout_rowWeight="1"
        app:layout_columnWeight="1"
        tools:ignore="HardcodedText"  />

    <Button
        android:id="@+id/digit8"
        android:text="8"
        style="@style/KeypadButton"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_weight="1"
        app:layout_rowWeight="1"
        app:layout_columnWeight="1"
        tools:ignore="HardcodedText"  />

    <Button
        android:id="@+id/digit9"
        android:text="9"
        style="@style/KeypadButton"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_weight="1"
        app:layout_rowWeight="1"
        app:layout_columnWeight="1"
        tools:ignore="HardcodedText" />

    <Button
        android:id="@+id/buttonPlus"
        android:text="+"
        style="@style/KeypadRightButton"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        app:layout_rowWeight="0.5"
        app:layout_columnWeight="1"
        tools:ignore="HardcodedText" />

    <!--row with 4-6, - -->

    <Button
        android:id="@+id/digit4"
        android:text="4"
        style="@style/KeypadLeftButton"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_weight="1"
        app:layout_rowWeight="1"
        app:layout_columnWeight="1"
        tools:ignore="HardcodedText" />

    <Button
        android:id="@+id/digit5"
        android:text="5"
        style="@style/KeypadButton"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_weight="1"
        app:layout_rowWeight="1"
        app:layout_columnWeight="1"
        tools:ignore="HardcodedText" />

    <Button
        android:id="@+id/digit6"
        android:text="6"
        style="@style/KeypadButton"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_weight="1"
        app:layout_rowWeight="1"
        app:layout_columnWeight="1"
        tools:ignore="HardcodedText"  />

    <Button
        android:id="@+id/buttonMinus"
        android:text="-"
        style="@style/KeypadRightButton"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        app:layout_rowWeight="0.5"
        app:layout_columnWeight="1"
        tools:ignore="HardcodedText" />

    <!--row with 1-3, * -->

    <Button
        android:id="@+id/digit1"
        android:text="1"
        style="@style/KeypadLeftButton"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_weight="1"
        app:layout_rowWeight="1"
        app:layout_columnWeight="1"
        tools:ignore="HardcodedText"  />

    <Button
        android:id="@+id/digit2"
        android:text="2"
        style="@style/KeypadButton"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_weight="1"
        app:layout_rowWeight="1"
        app:layout_columnWeight="1"
        tools:ignore="HardcodedText"  />

    <Button
        android:id="@+id/digit3"
        android:text="3"
        style="@style/KeypadButton"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_weight="1"
        app:layout_rowWeight="1"
        app:layout_columnWeight="1"
        tools:ignore="HardcodedText" />

    <Button
        android:id="@+id/buttonMultiply"
        android:text="\u22C5"
        style="@style/KeypadRightButton"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        app:layout_rowWeight="0.5"
        app:layout_columnWeight="1"
        tools:ignore="HardcodedText" />

    <!--row with 0, backspace and / -->

    <Button
        android:id="@+id/digit0"
        android:text="0"
        style="@style/KeypadLeftButton"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        app:layout_columnWeight="1"
        app:layout_gravity="fill_horizontal"
        app:layout_rowWeight="1"
        tools:ignore="HardcodedText"  />

    <Button
        android:id="@+id/buttonBackspace"
        android:text="←"
        style="@style/KeypadButton"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        app:layout_gravity="fill_vertical"
        app:layout_columnSpan="2"
        app:layout_rowWeight="0.5"
        app:layout_columnWeight="1"
        tools:ignore="HardcodedText" />

    <Button
        android:id="@+id/buttonDivide"
        android:text=":"
        style="@style/KeypadRightButton"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        app:layout_rowWeight="0.5"
        app:layout_columnWeight="1"
        tools:ignore="HardcodedText" />
</android.support.v7.widget.GridLayout>

<!--row with button submit -->

<Button
    android:id="@+id/buttonSubmit"
    android:text="@string/action_next_formula"
    style="@style/KeypadNextButton"
    android:layout_width="match_parent"
    android:layout_height="80dp"
    app:layout_gravity="fill_horizontal"/>
</LinearLayout>

стили:

<style name="Formula">
    <item name="android:textSize">@dimen/calc_button_text</item>
    <item name="android:textColor">@color/gray_35</item>
    <item name="android:gravity">center</item>
    <item name="android:background">@drawable/lcd</item>
    <item name="android:layout_marginTop">@dimen/calc_big_margin</item>
    <item name="android:layout_marginBottom">@dimen/calc_superbig_margin</item>
    <item name="android:layout_marginLeft">@dimen/calc_big_margin</item>
    <item name="android:layout_marginRight">@dimen/calc_big_margin</item>
</style>

<style name="KeypadButton" parent="@style/Widget.AppCompat.Button">
    <item name="android:textSize">@dimen/calc_button_text</item>
    <item name="android:textColor">@color/white</item>
    <!--<item name="android:background">@drawable/tl_2</item>-->
    <item name="android:layout_marginLeft">@dimen/calc_small_margin</item>
    <item name="android:layout_marginBottom">@dimen/calc_small_margin</item>
</style>

<style name="KeypadLeftButton" parent="@style/KeypadButton">
    <item name="android:layout_marginLeft">@dimen/calc_big_margin</item>
</style>

<style name="KeypadRightButton" parent="@style/KeypadButton">
    <item name="android:layout_marginRight">@dimen/calc_big_margin</item>
</style>

<style name="KeypadNextButton" parent="@style/Widget.AppCompat.Button.Colored">
    <item name="android:background">@drawable/tl_next</item>
    <item name="android:textSize">@dimen/calc_button_text</item>
    <item name="android:layout_marginTop">@dimen/calc_big_margin</item>
    <item name="android:layout_marginBottom">@dimen/calc_big_margin</item>
    <item name="android:layout_marginLeft">@dimen/calc_big_margin</item>
    <item name="android:layout_marginRight">@dimen/calc_big_margin</item>
</style>

Dimens:

<dimen name="calc_button_text">14sp</dimen>
<dimen name="calc_superbig_margin">2dp</dimen>
<dimen name="calc_big_margin">1dp</dimen>
<dimen name="calc_small_margin">0dp</dimen>

Обновление 16 февраля

Манджунатх Прабхакар сказал, что проблема может быть связана с весом. Поэтому я попытался удалить все весовые атрибуты, и теперь в макете больше смысла. Я еще не исправил это все же. Я бы подумал переписать макет для вложенных LinearLayouts в качестве шага назад, поэтому я открываю щедрость для других предложений.

Ответы на вопрос(2)

Ваш ответ на вопрос