I am trying to display a list
using an own layout
that's going to be populated with some info fetched from the server. I would like to create my own layout
(to use it in ListView
), to have in the right and left top corners some rounded views
, to display time and date. I have found an exemple online as follows:
My question it's: How can i achieve this? What must be done in the root layout
of the ListView
to create that round view
in the the corners? I have searched online and nothing popped. The layout
presented above it's a screenshot from another application, that uses the same logic. (Creating a ListView
with a root layout
)
I have found a solution, probably not the best way to do it but the outcome is as follows:
I have used a RelativeLayout
as parent, with 2 views aligned to left and right, and to make them go out of the parent, used on both android:marginStart
and android:marginEnd
plus android:marginTop
with negative values. The code is as follows:
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="wrap_content">
<RelativeLayout
android:layout_marginBottom="5dp"
android:layout_marginTop="5dp"
android:layout_marginStart="15dp"
android:layout_marginEnd="15dp"
android:layout_width="match_parent"
android:layout_height="120dp">
<TextView
android:layout_alignParentStart="true"
android:layout_marginStart="-8dp"
android:layout_marginTop="-10dp"
android:layout_width="50dp"
android:layout_height="50dp"
android:textColor="@color/white"
android:text="32''"
android:gravity="center"
android:paddingLeft="8dp"
android:paddingTop="8dp"
android:background="@drawable/buton_rotund_albastru" />
<TextView
android:layout_alignParentEnd="true"
android:layout_marginEnd="-8dp"
android:layout_marginTop="-10dp"
android:layout_width="50dp"
android:layout_height="50dp"
android:textColor="@color/white"
android:text="32''"
android:gravity="center"
android:paddingRight="8dp"
android:paddingTop="8dp"
android:background="@drawable/buton_rotund_albastru"/>
</RelativeLayout>
</RelativeLayout>
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.