Как получить этот конкретный макет карты в моем приложении? - PullRequest
0 голосов
/ 02 мая 2020

Я просто хочу попробовать этот макет для своего приложения, я уже пробовал использовать 2 отдельных вида карты, но скругленные границы не помогли. Я уже приложил изображение моего результата и мой код.

Мой код

</com.google.android.material.card.MaterialCardView>

    <HorizontalScrollView
        android:id="@+id/live_score_card"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_margin="10dp"
        android:layout_gravity="center">

        <LinearLayout
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:orientation="horizontal">

            <com.google.android.material.card.MaterialCardView
                android:id="@+id/scores"
                android:layout_width="150dp"
                android:layout_height="100dp"
                android:layout_marginEnd="10dp">
                <LinearLayout
                    android:layout_width="match_parent"
                    android:layout_height="wrap_content"
                    android:layout_marginTop="7dp">
                    <ImageView
                        android:id="@+id/team_emblem"
                        android:layout_width="40dp"
                        android:layout_height="40dp"
                        android:src="@drawable/rangers"
                        android:layout_marginLeft="10dp"/>
                    <TextView
                        android:id="@+id/team_name"
                        android:layout_width="wrap_content"
                        android:layout_height="wrap_content"
                        android:text="Rangers FC"
                        android:textColor="@color/colorPrimaryDark"
                        android:textSize="15sp"
                        android:layout_marginLeft="10dp"
                        android:layout_marginTop="10dp"/>

                </LinearLayout>

                <View
                    android:layout_width="wrap_content"
                    android:layout_height="1dp"
                    android:layout_gravity="center"
                    android:background="#F2161616" />

                <LinearLayout
                    android:layout_width="match_parent"
                    android:layout_height="wrap_content"
                    android:layout_marginBottom="7dp"
                    android:layout_gravity="bottom">

                    <ImageView
                        android:id="@+id/team_emblem"
                        android:layout_width="40dp"
                        android:layout_height="40dp"
                        android:src="@drawable/rangers"
                        android:layout_marginLeft="10dp"/>

                    <TextView
                        android:id="@+id/team_name"
                        android:layout_width="wrap_content"
                        android:layout_height="wrap_content"
                        android:text="Rangers FC"
                        android:textColor="@color/colorPrimaryDark"
                        android:textSize="20sp"
                        android:layout_marginLeft="10dp"/>

                </LinearLayout>

</com.google.android.material.card.MaterialCardView>

Фотографии:

enter image description here

enter image description here

Ответы [ 2 ]

1 голос
/ 02 мая 2020

Используйте этот макет для охвата карт:

Я сам использовал цвета и изображения. так что используйте правильные цвета и изображения в соответствии с вашими потребностями.

 <?xml version="1.0" encoding="utf-8"?>
    <com.google.android.material.card.MaterialCardView 
    xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    xmlns:app="http://schemas.android.com/apk/res-auto"
    app:cardBackgroundColor="@color/white"
    android:layout_margin="8dp"
    app:cardCornerRadius="15dp"
    app:cardElevation="4dp"
   >

    <LinearLayout
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:orientation="horizontal"
        android:weightSum="10">


        <LinearLayout
            android:layout_width="0dp"
            android:layout_height="wrap_content"
            android:layout_weight="7"
            android:orientation="vertical">

            <LinearLayout
                android:layout_width="match_parent"
                android:layout_height="wrap_content"
                android:layout_marginTop="7dp"
                android:padding="8dp"
                android:orientation="horizontal">

                <ImageView
                    android:layout_width="40dp"
                    android:layout_height="40dp"
                    android:layout_marginLeft="10dp"
                    android:src="@drawable/ic_launcher_background" />

                <TextView
                    android:layout_width="wrap_content"
                    android:layout_height="wrap_content"
                    android:layout_marginLeft="10dp"
                    android:layout_marginTop="10dp"
                    android:textSize="20sp"
                    android:text="Rangers FC"
                    android:textColor="@color/colorPrimaryDark"
                     />

            </LinearLayout>

            <View
                android:layout_width="wrap_content"
                android:layout_height="0.5dp"
                android:layout_gravity="center"
                android:background="#F2161616" />

            <LinearLayout
                android:layout_width="match_parent"
                android:layout_height="wrap_content"
                android:layout_gravity="bottom"
                android:padding="8dp"
                android:layout_marginBottom="7dp">

                <ImageView
                    android:id="@+id/team_emblem"
                    android:layout_width="40dp"
                    android:layout_height="40dp"
                    android:layout_marginLeft="10dp"
                    android:src="@drawable/ic_launcher_background" />

                <TextView
                    android:id="@+id/team_name"
                    android:layout_width="wrap_content"
                    android:layout_height="wrap_content"
                    android:layout_marginLeft="10dp"
                    android:gravity="center_vertical"
                    android:layout_marginTop="10dp"
                    android:text="Rangers FC"
                    android:textColor="@color/colorPrimaryDark"
                    android:textSize="20sp" />

            </LinearLayout>

        </LinearLayout>

        <View
            android:layout_width="0.5dp"
            android:layout_height="match_parent"
            android:layout_gravity="center"
            android:background="#F2161616" />

        <LinearLayout
            android:layout_width="0dp"
            android:orientation="vertical"
            android:layout_weight="3"
            android:gravity="center"
            android:layout_gravity="center"
            android:layout_height="match_parent">

            <TextView
                android:layout_width="wrap_content"
                android:text="5"
                android:textColor="@color/green"
                android:textStyle="bold"
                android:textSize="16sp"
                android:padding="8dp"
                android:layout_height="wrap_content"/>


            <TextView
                android:layout_width="wrap_content"
                android:text="35:43"
                android:layout_margin="8dp"
                android:textColor="@color/black"
                android:textSize="16sp"
                android:textStyle="bold"
                android:layout_height="wrap_content"/>


            <TextView
                android:layout_width="wrap_content"
                android:text="5"
                android:padding="8dp"
                android:textColor="@color/red"
                android:textSize="16sp"
                android:textStyle="bold"
                android:layout_height="wrap_content"/>

        </LinearLayout>

    </LinearLayout>

</com.google.android.material.card.MaterialCardView>

Happy Coding

Expected output is :

0 голосов
/ 02 мая 2020

Пожалуйста, реализуйте cardview-v7, это просто в использовании и реализации

dependencies {
    implementation'com.android.support:cardview-v7:21.0.0-rc1'
}

попробуйте таким образом

    <android.support.v7.widget.CardView
        android:id="@+id/card_view"
        xmlns:card_view="https://schemas.android.com/apk/res-auto"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        card_view:cardBackgroundColor="@color/grey_300"
        card_view:cardCornerRadius="10dp"
        card_view:cardElevation="5dp"
        card_view:cardUseCompatPadding="true">

               <LinearLayout
                    android:layout_width="match_parent"
                    android:layout_height="wrap_content"
                    android:layout_marginTop="7dp" 
                    android:orientation="verticle">

                  <LinearLayout
                    android:layout_width="match_parent"
                    android:layout_height="wrap_content"
                    android:layout_marginTop="7dp">
                    <ImageView
                        android:id="@+id/team_emblem"
                        android:layout_width="40dp"
                        android:layout_height="40dp"
                        android:src="@drawable/rangers"
                        android:layout_marginLeft="10dp"/>
                    <TextView
                        android:id="@+id/team_name"
                        android:layout_width="wrap_content"
                        android:layout_height="wrap_content"
                        android:text="Rangers FC"
                        android:textColor="@color/colorPrimaryDark"
                        android:textSize="15sp"
                        android:layout_marginLeft="10dp"
                        android:layout_marginTop="10dp"/>

                </LinearLayout>

                <View
                    android:layout_width="wrap_content"
                    android:layout_height="1dp"
                    android:layout_gravity="center"
                    android:background="#F2161616" />

                <LinearLayout
                    android:layout_width="match_parent"
                    android:layout_height="wrap_content"
                    android:layout_marginBottom="7dp"
                    android:layout_gravity="bottom">

                    <ImageView
                        android:id="@+id/team_emblem"
                        android:layout_width="40dp"
                        android:layout_height="40dp"
                        android:src="@drawable/rangers"
                        android:layout_marginLeft="10dp"/>

                    <TextView
                        android:id="@+id/team_name"
                        android:layout_width="wrap_content"
                        android:layout_height="wrap_content"
                        android:text="Rangers FC"
                        android:textColor="@color/colorPrimaryDark"
                        android:textSize="20sp"
                        android:layout_marginLeft="10dp"/>

                </LinearLayout>
            </LinearLayout>

    </android.support.v7.widget.CardView>

Спасибо

...