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>

在此处输入图像描述

如何消除 Lorem 的 L 和进度条之间的差距?我希望文本仅居中对齐。

textview 宽度是换行内容。但是两边都有差距。如何摆脱它?

我也不希望单行它。因为我不想错过它显示的任何单词。

我也不想让它左对齐

4

4 回答 4

1

在您的 textView 中进行此更改::

<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"/>
于 2012-12-05T11:41:54.317 回答
0

尝试

android:gravity="center|left"
于 2012-12-05T11:56:10.043 回答
0
style="?android:attr/progressBarStyleSmall"
android:layout_width="0dp"
android:layout_weight="1"

将 progressBar 的权重设置为 1 并将宽度设置为 0dp 您可以获得所需的结果,但不能保证它适用于所有屏幕尺寸

编辑:

通过上述更改,我能够获得所需的输出。

上述变化的结果

于 2012-12-05T12:05:37.443 回答
0

尝试使用这个:

<?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>
于 2012-12-05T12:45:32.430 回答