макет приложения перекрывается на небольших дисплеях - PullRequest
0 голосов
/ 23 сентября 2018

Я создал домашнюю страницу для своего приложения с дизайном плитки, но моя последняя плитка наполовину скрыта на устройствах размером менее 5 дюймов.Пожалуйста помоги!!Я думаю, что приложение не изменяет размеры в этих устройствах, плитки не сжимаются.Я новичок в разработке приложений для Android.

Приведенный ниже код - это мой activity_home.xml, и это скриншот того, как мое приложение выглядит на 5-дюймовом устройстве.

this is the screenshot of what my app looks in an 5 inch device

Вы видите последнюю плитку под двумя верхними.Почему это происходит?

     <?xml version="1.0" encoding="utf-8"?>
   <LinearLayout 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:layout_width="match_parent"
android:layout_height="match_parent"
tools:context=".Home"
android:orientation="vertical"
android:padding="10dp"
android:background="@color/backgroundcolor"
android:gravity="center"
>
<LinearLayout
    android:clipChildren="false"
    android:gravity="center"
    android:orientation="horizontal"
    android:layout_width="match_parent"
    android:layout_height="wrap_content">
    <android.support.v7.widget.CardView
        android:foreground="?android:attr/selectableItemBackground"
        android:clickable="true"

        android:layout_width="160dp"
        android:layout_height="190dp"
        android:layout_margin="10dp">
    <LinearLayout
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:orientation="vertical"
        android:gravity="center">
        <ImageView
            android:layout_width="64dp"
            android:layout_height="64dp"
            android:background="@drawable/cerclebackgroundpurple"
            android:src="@drawable/ic_attach_money_black_24dp"
            android:padding="10dp"
            />
        <TextView
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:textStyle="bold"
            android:layout_marginTop="10dp"
            android:text="Banking"/>
        <View
            android:layout_width="match_parent"
            android:layout_height="1dp"
            android:background="@color/lightgray"
            android:layout_margin="10dp"/>
        <TextView
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:gravity="center"
            android:text="Check your bank activities"
            android:padding="5dp"
            android:textColor="@android:color/darker_gray"
            />
    </LinearLayout>
    </android.support.v7.widget.CardView>
    <android.support.v7.widget.CardView
        android:foreground="?android:attr/selectableItemBackground"
        android:clickable="true"
        android:layout_width="160dp"
        android:layout_height="190dp"
        android:layout_margin="10dp">
        <LinearLayout
            android:layout_width="match_parent"
            android:layout_height="match_parent"
            android:orientation="vertical"
            android:gravity="center">
            <ImageView
                android:layout_width="64dp"
                android:layout_height="64dp"
                android:background="@drawable/cerclebackgroundpink"
                android:src="@drawable/ic_lightbulb_outline_black_24dp"
                android:padding="10dp"
                />
            <TextView
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:textStyle="bold"
                android:layout_marginTop="10dp"
                android:text="Ideas"/>
            <View
                android:layout_width="match_parent"
                android:layout_height="1dp"
                android:background="@color/lightgray"
                android:layout_margin="10dp"/>
            <TextView
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:gravity="center"
                android:text="Check your bank activities"
                android:padding="5dp"
                android:textColor="@android:color/darker_gray"
                />
        </LinearLayout>
    </android.support.v7.widget.CardView>
</LinearLayout>

<LinearLayout
    android:clipChildren="false"
    android:gravity="center"
    android:orientation="horizontal"
    android:layout_width="match_parent"
    android:layout_height="wrap_content">
    <android.support.v7.widget.CardView
        android:foreground="?android:attr/selectableItemBackground"
        android:clickable="true"
        android:layout_width="160dp"
        android:layout_height="190dp"
        android:layout_margin="10dp">
        <LinearLayout
            android:layout_width="match_parent"
            android:layout_height="match_parent"
            android:orientation="vertical"
            android:gravity="center">
            <ImageView
                android:layout_width="64dp"
                android:layout_height="64dp"
                android:background="@drawable/cerclebackgroundgreen"
                android:src="@drawable/ic_control_point_black_24dp"
                android:padding="10dp"
                />
            <TextView
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:textStyle="bold"
                android:layout_marginTop="10dp"
                android:text="Add"/>
            <View
                android:layout_width="match_parent"
                android:layout_height="1dp"
                android:background="@color/lightgray"
                android:layout_margin="10dp"/>
            <TextView
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:gravity="center"
                android:text="Check your bank activities"
                android:padding="5dp"
                android:textColor="@android:color/darker_gray"
                />
        </LinearLayout>
    </android.support.v7.widget.CardView>
    <android.support.v7.widget.CardView
        android:layout_width="160dp"
        android:layout_height="190dp"
        android:layout_margin="10dp">
        <LinearLayout
            android:foreground="?android:attr/selectableItemBackground"
            android:clickable="true"

            android:layout_width="match_parent"
            android:layout_height="match_parent"
            android:orientation="vertical"
            android:gravity="center">
            <ImageView
                android:layout_width="64dp"
                android:layout_height="64dp"
                android:background="@drawable/cerclebackgroundyello"
                android:src="@drawable/ic_attach_file_black_24dp"
                android:padding="10dp"
                />
            <TextView
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:textStyle="bold"
                android:layout_marginTop="10dp"
                android:text="Links"/>
            <View
                android:layout_width="match_parent"
                android:layout_height="1dp"
                android:background="@color/lightgray"
                android:layout_margin="10dp"/>
            <TextView
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:gravity="center"
                android:text="Check your bank activities"
                android:padding="5dp"
                android:textColor="@android:color/darker_gray"
                />
        </LinearLayout>
    </android.support.v7.widget.CardView>
</LinearLayout>

<LinearLayout
    android:clipChildren="false"
    android:gravity="center"
    android:orientation="horizontal"
    android:layout_width="match_parent"
    android:layout_height="wrap_content">
    <android.support.v7.widget.CardView
        android:layout_width="340dp"
        android:layout_height="150dp"
        android:layout_margin="10dp">
        <LinearLayout
            android:foreground="?android:attr/selectableItemBackground"
            android:clickable="true"

            android:layout_width="match_parent"
            android:layout_height="match_parent"
            android:orientation="vertical"
            android:gravity="center">
            <ImageView
                android:layout_width="64dp"
                android:layout_height="64dp"
                android:background="@drawable/cerclebackgroundpurple"
                android:src="@drawable/ic_wifi_black_24dp"
                android:padding="10dp"
                />
            <TextView
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:textStyle="bold"
                android:layout_marginTop="10dp"
                android:text="Add"/>
            <View
                android:layout_width="match_parent"
                android:layout_height="1dp"
                android:background="@color/lightgray"
                android:layout_margin="10dp"/>
            <TextView
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:gravity="center"
                android:text="Check your bank activities"
                android:padding="5dp"
                android:textColor="@android:color/darker_gray"
                />
        </LinearLayout>
    </android.support.v7.widget.CardView>

</LinearLayout>

1 Ответ

0 голосов
/ 23 сентября 2018

Есть несколько вариантов, которых вы можете достичь.

1.Вы можете поместить его в прокрутку, если хотите фиксированный размер.Вы можете сделать полосу прокрутки невидимой.

Вы можете использовать вес, чтобы разделить высоту равномерно.

Вы можете определить высоту в файле измерения.xml и создать отдельный файл измерений, чтобы определить высоты для небольших экранов.

Добро пожаловать на сайт PullRequest, где вы можете задавать вопросы и получать ответы от других членов сообщества.
...