Android 自定义listview中progressbar的相同纵横比

Android 自定义listview中progressbar的相同纵横比,android,android-layout,progress-bar,Android,Android Layout,Progress Bar,我有一个自定义行布局的列表视图。此自定义行中有一个progressbar(“圆”),表示加载状态。为了使布局看起来像我喜欢的那样,我对progressbar和包含其他gui内容的布局使用了布局权重 例如: <ProgressBar android:id="@+id/progressBar1" style="?android:attr/progressBarStyleSmall" android:layout_width="0dip" android:lay

我有一个自定义行布局的列表视图。此自定义行中有一个progressbar(“圆”),表示加载状态。为了使布局看起来像我喜欢的那样,我对progressbar和包含其他gui内容的布局使用了布局权重

例如:

<ProgressBar
    android:id="@+id/progressBar1"
    style="?android:attr/progressBarStyleSmall"
    android:layout_width="0dip" 
    android:layout_height="match_parent" 
    android:layout_weight="1" />


<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" 
    android:layout_width="0dip" 
    android:layout_height="match_parent" 
    android:layout_weight="7"
    android:layout_marginLeft="6dip" 
    android:orientation="vertical"
    >

我希望progressbar具有相同的纵横比

我的问题是progressbar在不同的设备上看起来很奇怪。在我的galaxy nexus上,一切看起来都很好,progressbar具有相同的纵横比。但是在我的模拟器上,progressbar看起来像一个鸡蛋,这很糟糕

有人能指出我的错误吗

编辑:

我不使用wrap_内容,因为布局将使用progressbar的宽度显示视图的其余部分,这非常小(因此没有放置文本的位置)

Edit2:

显示问题的两张图片:

“鸡蛋”

wrap_内容的使用

Edit3:

CFlex的方法。整个xml文件

<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" 
android:layout_width="fill_parent" 
android:layout_height="wrap_content" 
android:orientation="horizontal">

<ProgressBar
    android:id="@+id/progressBar1"
    style="?android:attr/progressBarStyleSmall"
    android:layout_width="wrap_content" 
    android:layout_height="match_parent" 
    android:layout_gravity="center"
    android:layout_margin="4dp"/>


<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" 
    android:layout_width="0dip" 
    android:layout_height="match_parent" 
    android:layout_weight="7"
    android:layout_marginLeft="6dip" 
    android:orientation="vertical"
    >

    <TextView 
        android:id="@android:id/text1" 
        android:layout_width="fill_parent" 
        android:layout_height="wrap_content" 
        android:textAppearance="?android:attr/textAppearanceLarge"/>

    <TextView 
        android:id="@android:id/text2" 
        android:layout_width="fill_parent" 
        android:layout_height="wrap_content" 
        android:textAppearance="?android:attr/textAppearanceSmall"/>

</LinearLayout>


你为什么不试试这样的东西:

<ProgressBar
    android:id="@+id/progressBar1"
    style="?android:attr/progressBarStyleSmall"
    android:layout_width="wrap_content" 
    android:layout_height="match_parent"  
    android:layout_gravity="center"
    android:layout_margin="4dp"/>


<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" 
    android:layout_width="0dp" 
    android:layout_height="match_parent" 
    android:layout_weight="1"
    android:layout_marginLeft="6dip" 
    android:orientation="vertical"
    >

你为什么不试试这样的东西:

<ProgressBar
    android:id="@+id/progressBar1"
    style="?android:attr/progressBarStyleSmall"
    android:layout_width="wrap_content" 
    android:layout_height="match_parent"  
    android:layout_gravity="center"
    android:layout_margin="4dp"/>


<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" 
    android:layout_width="0dp" 
    android:layout_height="match_parent" 
    android:layout_weight="1"
    android:layout_marginLeft="6dip" 
    android:orientation="vertical"
    >


为什么你不使用包装内容,而不是在我的问题中给match_parent和0 Dip。无法使用换行内容,因为我的布局将被破坏。您可以将样式设置为progressbar,如small、normal和large。e、 g.style=“?android:attr/progressBarStyleSmall”谢谢,我试过了。没有“progressBarStyleNormal”资源。使用“小”时,高度用于整行布局(见图二),但太小。对于大的,它看起来也很糟糕。也许我的布局方法完全错误?如果您使用线性布局代替进度条(具有所需的尺寸),然后将进度条(具有
wrap\u content
)放置在该布局内,会怎么样?我认为应该这样做:布局的显式尺寸将确保布局的其余部分不会被切断,进度条上的
wrap\u content
将确保它不会被扭曲。为什么不使用wrap content,而不是在progressBar中提供match\u parent和0dip。无法使用换行内容,因为我的布局将被破坏。您可以将样式设置为progressbar,如small、normal和large。e、 g.style=“?android:attr/progressBarStyleSmall”谢谢,我试过了。没有“progressBarStyleNormal”资源。使用“小”时,高度用于整行布局(见图二),但太小。对于大的,它看起来也很糟糕。也许我的布局方法完全错误?如果您使用线性布局代替进度条(具有所需的尺寸),然后将进度条(具有
wrap\u content
)放置在该布局内,会怎么样?我认为它应该做到这一点:布局的显式尺寸将确保布局的其余部分不会被切断,进度条上的
wrap\u content
将确保它不会被扭曲。@eftokay83确实,这很奇怪。你能发布你的整个xml吗?@eftokay83你有没有试过用android:layout\u width=“match\u parent”作为水平线布局?是的,如果我为第二个布局设置它,结果是一样的。如果我将其设置为progressbar,结果是progressbar将获取所有可用空间。屏幕上除了progressbar之外什么都没有:)哦,我认为混合使用fill\u parent和match\u parent是肮脏的,但它是一样的。@eftokay83我用relativeLayout编辑了我的代码。告诉我问题是否解决了!非常感谢。但仍然不完美-你知道我如何用相同的纵横比拉伸progressbar吗?但是非常感谢@CFlex@事实上,这很奇怪。你能发布你的整个xml吗?@eftokay83你有没有试过用android:layout\u width=“match\u parent”作为水平线布局?是的,如果我为第二个布局设置它,结果是一样的。如果我将其设置为progressbar,结果是progressbar将获取所有可用空间。屏幕上除了progressbar之外什么都没有:)哦,我认为混合使用fill\u parent和match\u parent是肮脏的,但它是一样的。@eftokay83我用relativeLayout编辑了我的代码。告诉我问题是否解决了!非常感谢。但仍然不完美-你知道我如何用相同的纵横比拉伸progressbar吗?但是非常感谢@CFlex!