在线时间:8:00-16:00
迪恩网络APP
随时随地掌握行业动态
扫描二维码
关注迪恩网络微信公众号
开源软件名称:Kaopiz/android-segmented-control开源软件地址:https://github.com/Kaopiz/android-segmented-control开源编程语言:Java 100.0%开源软件介绍:android-segmented-controlAndroid-Segmented is a custom view for Android which is based on RadioGroup and RadioButton widget. This implementation is inspired by Segmented Controls for iOS. Including in your project:Download source code and import as moduleThe latest code has bug fixes, iOS 7's (and up) style segment control (which has nice fade animation and tint) and support for Font Awesome. (These features has not been pushed to Maven yet) Using mavenAndroid-Segmented Library is pushed to Maven Central, so you just need to add the following dependency to your
ManuallyCopy(or merge) below files into corresponding file/folder:
UsageDefine in xml like this and make sure that the <attr name="sc_corner_radius" format="dimension" />
<attr name="sc_border_width" format="dimension" />
<attr name="sc_tint_color" format="color" />
<attr name="sc_checked_text_color" format="color" /> Sample code: <info.hoang8f.android.segmented.SegmentedGroup
xmlns:segmentedgroup="http://schemas.android.com/apk/res-auto"
android:id="@+id/segmented2"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_margin="10dp"
android:orientation="horizontal"
segmentedgroup:sc_border_width="2dp"
segmentedgroup:sc_corner_radius="10dp">
<RadioButton
android:id="@+id/button21"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="One"
style="@style/RadioButton" />
<RadioButton
android:id="@+id/button22"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Two"
style="@style/RadioButton" />
</info.hoang8f.android.segmented.SegmentedGroup> You also can be change the tint color and title color when button is checked by SegmentedGroup segmented2 = (SegmentedGroup) rootView.findViewById(R.id.segmented2);
segmented2.setTintColor(Color.DKGRAY);
SegmentedGroup segmented3 = (SegmentedGroup) rootView.findViewById(R.id.segmented3);
segmented3.setTintColor(Color.parseColor("#FFD0FF3C"), Color.parseColor("#FF7B07B2"));
SegmentedGroup segmented4 = (SegmentedGroup) rootView.findViewById(R.id.segmented4);
segmented4.setTintColor(getResources().getColor(R.color.radio_button_selected_color)); If you dont specify border_width and/or corner_radius the default values will be used (1dp for border_width and 5 dp for corner_radius) CreditsAuthor:
License
|
2023-10-27
2022-08-15
2022-08-17
2022-09-23
2022-08-13
请发表评论