【问题标题】:How to put a ListView title in an Android bubble如何将 ListView 标题放入 Android 气泡中
【发布时间】:2019-04-16 00:04:11
【问题描述】:

我需要放置the date as the title of a Listviewinside a bubble,有人可以告诉我该怎么做。

这是放置date as a title:的代码

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

通过这段代码我得到了这个:

但我需要这样的标题:

这是创建气泡的文件: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" />

【问题讨论】:

    标签: android android-listview android-xml


    【解决方案1】:

    您可以创建这样的布局

    <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>
    

    将此布局居中对齐

    圆角白色

    <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>
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2013-11-02
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多