我正在使用来自https://github.com/Kaopiz/android-segmented-control的分段控制,它工作得很好,除了最后一个按钮总是像这样被挤压:
我正在使用简单的布局动态添加 RadioButtons:
<RadioButton xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="1"
style="@style/RadioButton" />
我尝试了类似 Layout_width="wrap content" 和删除 "layout_weight" 的变体——结果相同。分段控件本身的父布局也没有给出任何提示:
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginLeft="15dp"
android:layout_marginRight="15dp"
android:background="@color/white"
android:gravity="center"
android:minHeight="60dp">
<info.hoang8f.android.segmented.SegmentedGroup
android:id="@+id/segmentedGroup"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal"
segmentedgroup:sc_border_width="1dp"
segmentedgroup:sc_corner_radius="10dp"
segmentedgroup:sc_tint_color="#FFEB3B">
</info.hoang8f.android.segmented.SegmentedGroup>
</RelativeLayout>