android - Show time in message blocks -
android - Show time in message blocks -
i have message blocks.i want show time right bottom of message.this xml:
<?xml version="1.0" encoding="utf-8"?> <linearlayout xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="match_parent" android:layout_height="wrap_content" android:orientation="vertical"> <linearlayout android:id="@+id/blocks" android:layout_width="match_parent" android:layout_height="wrap_content" android:background="@drawable/mes7" android:layout_marginright="6dp" android:layout_marginleft="6dp" android:clickable="false"> <textview android:id="@+id/messagebar" android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_gravity="left" android:layout_marginleft="4dp" android:layout_marginright="6dp" android:gravity="left" android:paddingleft="5dp" android:paddingright="5dp" android:paddingtop="1dp" android:text="test message" android:typeface="sans" android:textsize="14sp"/> <textview android:id="@+id/date" android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_gravity="right|bottom" android:layout_marginright="5dp" android:text="19:40" android:textsize="10sp"/> </linearlayout> </linearlayout>
i have no problem short messages when message prolonged date not showing.here can see:
and 1 more thing:i want margin left border can't.
how can these ?
you have wrap linearlayout
around each 1 of textviews
, can utilize andorid:gravity
attribute in textviews
accuratly. define width weight value each 1 of linearlayouts
, time showing, no matter how many lines text message has. have utilize android:weightsum
attribute in parent layout (the root linearlayout
) ,set android:layout_width
values of linearlayouts
0dp
, lastly applying percentage of width space in each 1 of linearlayouts
, using android:layout_weight
attribute. assure width values constant , relative device screen width.
try this:
<linearlayout android:layout_width="0dp" android:layout_height="wrap_content" android:layout_weight="0.8" android:gravity="center" > <textview android:id="@+id/messagebar" android:layout_width="match_parent" android:layout_height="wrap_content" android:gravity="center_vertical" android:text="test message has big can test test here" android:textsize="14sp" android:typeface="sans" /> </linearlayout> <linearlayout android:layout_width="0dp" android:layout_height="wrap_content" android:layout_gravity="bottom|right" android:layout_weight="0.2" android:clickable="false" > <textview android:id="@+id/date" android:layout_width="match_parent" android:layout_height="wrap_content" android:layout_gravity="center" android:gravity="center" android:singleline="true" android:text="19:40" android:textsize="12sp" /> </linearlayout>
android android-layout
Comments
Post a Comment