You should change LinearLayout
to RelativeLayout
. as well as you can assign android:ellipsize="marquee"
or android:ellipsize="end"
to the First title_txt
Even I had changed the width of LinearLayout
containing Battery Percentage and Timer from android:layout_width="fill_parent"
to android:layout_width="wrap_content"
doesn't matter your text of title increase or decrease timer and and percentage will remain at the right side.
Try With Following Code.
<RelativeLayout
android:id="@+id/top_panel"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_gravity="top"
android:background="#45000000"
android:gravity="center_vertical"
android:orientation="horizontal" >
<TextView
android:id="@+id/title_txt"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentLeft="true"
android:layout_toLeftOf="@+id/ll_timer_battery_perc"
android:ellipsize="marquee"
android:lines="1"
android:marqueeRepeatLimit="marquee_forever"
android:paddingLeft="5dp"
android:text="abcdefghijklmnopqrstuvwxyz1234567"
android:textColor="#ffffff"
android:textSize="15sp"
android:textStyle="bold" />
<LinearLayout
android:id="@+id/ll_timer_battery_perc"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentRight="true"
android:gravity="right"
android:orientation="horizontal" >
<TextView
android:id="@+id/batPer"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginRight="8dp"
android:lines="1"
android:text="100%"
android:textSize="17sp"
android:textStyle="bold" />
<TextView
android:id="@+id/timetxt"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:lines="1"
android:text="03:07AM"
android:textColor="#ffffff"
android:textSize="17sp"
android:textStyle="bold" />
</LinearLayout>
</RelativeLayout>