Reputation: 13815
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="horizontal"
android:gravity="center"
android:layout_width="fill_parent"
android:layout_height="wrap_content">
<ProgressBar android:id="@+android:id/progress_small"
style="?android:attr/progressBarStyleSmall"
android:layout_width="wrap_content"
android:layout_height="wrap_content" />
<TextView android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textSize="15sp"
android:gravity="center"
android:text="LOREM IPSUM BAB BABALOREM IPSUM BAB BABALOREM"
/>
</LinearLayout>
How to remove the Gap between L of Lorem and the progress bar ? I want text to be center aligned only.
textview width is wrap content. But there is gap on both the side. How to get rid of that ?
Neither i am looking to single line it. as i don't want to miss any word it is showing.
Neither i am looking to left align it
Upvotes: 1
Views: 1666
Reputation: 196
style="?android:attr/progressBarStyleSmall"
android:layout_width="0dp"
android:layout_weight="1"
Setting the weight of progressBar to 1 and width to 0dp you can get desired result but cannot guarantee that it will work in all screen dimensions
EDIT:
With the above changes, I was able to get the desired output.
Upvotes: 0
Reputation: 6927
try using this:
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="horizontal"
android:gravity="center"
android:layout_width="wrap_content"
android:layout_height="wrap_content">
<ProgressBar android:id="@+id/ProgressDisplay"
style="?android:attr/progressBarStyleSmall"
android:layout_width="wrap_content"
android:layout_height="wrap_content" />
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_toRightOf="@id/ProgressDisplay"
android:gravity="left"
android:text="LOREM IPSUM BAB BABALOREM IPSUM BAB BABALOREM"
android:textSize="15sp" />
</RelativeLayout>
Upvotes: 0
Reputation: 4636
In your textView make this changes ::
<TextView android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textSize="15sp"
android:gravity="center"
android:singleLine="True"
android:text="LOREM IPSUM BAB BABALOREM IPSUM BAB BABALOREM"/>
Upvotes: 1