Рисование строки заголовка вверху CardView - PullRequest
0 голосов
/ 19 июня 2019

Я пытаюсь нарисовать строку заголовка в верхней части представления карты.
Это то, что я получаю (также почему не рисуется текст "Заголовок теста здесь"?

https://imgur.com/cJqrzih

но я ищу это

enter image description here

Это 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:layout_width="match_parent"
    android:layout_height="match_parent"
    tools:context=".MainActivity">

    <android.support.v7.widget.CardView
        android:id="@+id/card"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:layout_centerHorizontal="true"
        android:innerRadius="0dp"
        android:shape="ring"
        android:thicknessRatio="1.9"
        app:cardCornerRadius="40dp"
        app:contentPadding="13dp"
        tools:layout_editor_absoluteY="35dp">

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

            <TextView
                android:id="@+id/header_when"
                android:layout_width="match_parent"
                android:layout_height="wrap_content"
                android:background="#D3D3D3"
                android:textColor="#000000"
                android:textStyle="bold"
                android:padding="8dp"
                tools:text="Test Title Goes Here" />

            <com.google.android.flexbox.FlexboxLayout
                android:id="@+id/layout"
                android:layout_width="match_parent"
                android:layout_height="match_parent"
                app:alignContent="stretch"
                app:alignItems="stretch"
                app:flexDirection="row"
                app:flexWrap="wrap"
                app:justifyContent="flex_start">

            </com.google.android.flexbox.FlexboxLayout>

        </LinearLayout>

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

</android.support.constraint.ConstraintLayout>

Любая помощь очень ценится

1 Ответ

1 голос
/ 19 июня 2019

Передача XML для вашего textview должна помочь вам. Добавьте xml в качестве фона для textview в основной макет xml. В пользовательском текстовом представлении xml сделайте что-то вроде этого: -

<?xml version="1.0" encoding="UTF-8"?> 
<shape xmlns:android="http://schemas.android.com/apk/res/android"> 
    <solid android:color="#ffffffff"/>    

    <stroke android:width="3dp"
            android:color="#ff000000" />

    <padding android:left="1dp"
             android:top="1dp"
             android:right="1dp"
             android:bottom="1dp" /> 

    <corners android:bottomRightRadius="7dp"
             android:bottomLeftRadius="7dp"
             android:topLeftRadius="7dp"
             android:topRightRadius="7dp" /> 
</shape> 

Надеюсь, это поможет.

...