Как поместить заголовок ListView в пузырь Android - PullRequest
0 голосов
/ 16 апреля 2019

Мне нужно разместить the date as the title of a Listview, но inside a bubble, кто-то может сказать мне, как это сделать.

Вот код для размещения date as a title:

readFechaActual();
TextView textView = new TextView(context);
textView.setText(stringDate);
listView.addHeaderView(textView);

С этим кодом я получаю:

enter image description here

Но для чего мне нужен такой заголовок:

enter image description here

Вот файл для создания пузыря: drawable/time_message.xml:

<shape xmlns:android="http://schemas.android.com/apk/res/android"
android:shape="rectangle">
<solid android:color="@color/SALMON" />
<corners android:radius="20dp" />

1 Ответ

0 голосов
/ 16 апреля 2019

Вы можете создать макет, подобный этому

<RelativeLayout
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:background="@drawable/round_corner_white"
  >


    <TextView
        android:id="@+id/tv_search_what"
        style="@style/gray_12_l"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:layout_centerInParent="true"
      />

</RelativeLayout>

выровнять этот макет по центру

round_corner_white

<shape xmlns:android="http://schemas.android.com/apk/res/android">
    <solid android:color="@color/white"/>
    <stroke android:width="0.5dp" android:color="@color/blue" />
    <corners android:radius="@dimen/_20sdp"/>
    <corners
        android:bottomLeftRadius="@dimen/_20sdp"
        android:bottomRightRadius="@dimen/_20sdp"
        android:topLeftRadius="@dimen/_20sdp"
        android:topRightRadius="@dimen/_20sdp" />
</shape>
...