Android 如何使用支持率库在布局中奇数个视图之间平均分配空间?

Android 如何使用支持率库在布局中奇数个视图之间平均分配空间?,android,android-layout,android-support-library,android-percent-library,percent-support-library,Android,Android Layout,Android Support Library,Android Percent Library,Percent Support Library,我正在项目中使用支持百分比库 编译'com.android.support:percent:23.1.0' 我有三个线性布局的图像视图,它们应该平均地占据空间(水平方向)。但由于percent support library只有PercentRelativeLayout和PercentFrameLayout,所以我搜索了PercentLinearLayout并找到了它 以下是布局代码: <com.example.layouts.PercentLinearLayout android

我正在项目中使用支持百分比库

编译'com.android.support:percent:23.1.0'

我有三个线性布局的图像视图,它们应该平均地占据空间(水平方向)。但由于percent support library只有PercentRelativeLayout和PercentFrameLayout,所以我搜索了PercentLinearLayout并找到了它

以下是布局代码:

<com.example.layouts.PercentLinearLayout
    android:layout_width="match_parent"
    android:layout_height="100dp"
    android:orientation="horizontal">

    <ImageView
        android:layout_width="0dp"
        android:layout_height="match_parent"
        android:background="@drawable/img_01"
        app:layout_widthPercent="33.3%" />  // <- what should I write here?

    <ImageView
        android:layout_width="0dp"
        android:layout_height="match_parent"
        android:background="@drawable/img_02"
        app:layout_widthPercent="33.3%" />  // <- and here..

    <ImageView
        android:layout_width="0dp"
        android:layout_height="match_parent"
        android:background="@drawable/img_03"
        app:layout_widthPercent="33.3%" /> // <- and here..

</com.example.layouts.PercentLinearLayout>


//您可以使用
LinearLayout
并将
weightSum
设置为3和
android:layout\u weight=“1”
对每个
ImageView

如果您想使用百分比,可以将
weightSum
设置为100,然后将
android:layou weight
设置为您想要的百分比数。

您可以实现这一点,而无需使用支持库,而是使用带有权重的线性布局,并将图像视图嵌套在线性布局中。make它是33.333%,那么只剩下0.001%。“之前我使用了权重(每个ImageView的权重为1),但因为它对性能不好”--请发布您的性能分析,显示您对
LinearLayout
和相等权重的具体使用“对性能不好”,无论是在绝对的基础上,还是与你在这里尝试的东西相比。所有布局在某种程度上都“不利于性能”。@activesince93:这并不能真正回答问题。@Commonware:好的。假设我在另一个布局中有这个PercentLinearLayout,并为它分配了一些权重。我认为嵌套权重对性能不好,对吗?这正是我之前所做的。我想知道如何使用百分比支持库来处理这种情况。