android - Center alignment inside LinearLayout -



android - Center alignment inside LinearLayout -

i need align message , time center of screen. code

<?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="horizontal" android:paddingtop="10dp" android:paddingleft="10dp" android:paddingright="10dp" android:gravity="center_horizontal"> <textview android:id="@+id/tvmessage" android:gravity="center_vertical" android:layout_width="wrap_content" android:layout_height="wrap_content" android:autolink="web|email" android:textsize="@dimen/system_msg_text_size" android:textcolor="@android:color/darker_gray" android:text="message"/> <textview android:id="@+id/tvtime" android:gravity="center_vertical" android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_marginright="10dp" android:layout_marginleft="5dp" android:text="time" android:singleline="true" android:textsize="@dimen/system_msg_text_size" android:textcolor="@android:color/darker_gray"/> </linearlayout>

i see

and it's ok

but when message longer see ellipsize

i tried set android:ellipsize="none" sec textview

now see cropped text "time" - no 'e' character

i want see wrapping first textview without cropping sec textview alignment both center.

i suggest utilize relativelayout instead of linearlayout. , then, give layout_alignparentleft true message textview, , layout_alignparentright true time textview, :

<?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" android:gravity="center_horizontal" android:orientation="horizontal" android:paddingleft="10dp" android:paddingright="10dp" android:paddingtop="10dp" > <textview android:id="@+id/tvmessage" android:layout_width="wrap_content" android:layout_height="wrap_content" android:autolink="web|email" android:layout_alignparentleft="true" android:layout_toleftof="@+id/tvtime" android:gravity="center_vertical" android:text="message long long long long long long long long" android:textcolor="@android:color/darker_gray" android:textsize="15sp" /> <textview android:id="@+id/tvtime" android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_alignparentright="true" android:layout_marginleft="5dp" android:layout_marginright="10dp" android:gravity="center_vertical" android:text="time" android:textcolor="@android:color/darker_gray" android:textsize="15sp" /> </relativelayout>

the result :

android android-layout alignment android-linearlayout

Comments

Popular posts from this blog

php - Android app custom user registration and login with cookie using facebook sdk -

django - Access session in user model .save() -

php - .htaccess Multiple Rewrite Rules / Prioritizing -