1
<?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>

enter image description here

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

Rohit Sharma
  • 13,787
  • 8
  • 57
  • 72
  • I dont think you can achieve what you're aiming for on purpose, i think it comes down to how android wraps the words etc, adding a short word might push the first line more to the left. Thats at least whats happens on my S2 – Stupidus Dec 05 '12 at 12:37

4 Answers4

1

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"/>
AndroidLearner
  • 4,500
  • 4
  • 31
  • 62
0

Try

android:gravity="center|left"
Stupidus
  • 461
  • 3
  • 10
0
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.

Result of above changes

Mani
  • 186
  • 5
0

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>
Ankush
  • 6,767
  • 8
  • 30
  • 42