diff --git a/README.md b/README.md index e3ab187..70329fe 100644 --- a/README.md +++ b/README.md @@ -22,6 +22,7 @@ Copy(or merge) below files into corresponding file/folder: + res/drawable-v14/* + res/values/colors.xml + res/values/dimens.xml + + res/values/attrs.xml + res/values/styles.xml (only RadioButton style) Usage @@ -52,15 +53,28 @@ Define in xml like this and make sure that the `RadioButton`'s style is: `@style ``` +Attributes +---------- + +* ```app:tint_color``` (color) +* ```app:checked_color``` (color) +* ```app:pressed_tint_color``` (color) +* ```app:pressed_stroke_color``` (color) +* ```app:text_color``` (color) +* ```app:pressed_text_color``` (color) + You also can be change the tint color and title color when button is checked by `setTintColor` method. +Also you can change the pressed tint color by `setPressedTintColor` method. Here is sample code: ```java SegmentedGroup segmented2 = (SegmentedGroup) rootView.findViewById(R.id.segmented2); segmented2.setTintColor(Color.DKGRAY); +segmented2.setPressedTintColor(Color.LTGRAY, Color.DKGRAY); SegmentedGroup segmented3 = (SegmentedGroup) rootView.findViewById(R.id.segmented3); segmented3.setTintColor(Color.parseColor("#FFD0FF3C"), Color.parseColor("#FF7B07B2")); +segmented3.setPressedTintColor(Color.parseColor("#DDD0FF3C"), Color.parseColor("#FFD0FF3C")); SegmentedGroup segmented4 = (SegmentedGroup) rootView.findViewById(R.id.segmented4); segmented4.setTintColor(getResources().getColor(R.color.radio_button_selected_color)); diff --git a/build.gradle b/build.gradle index 1879c21..aca5742 100644 --- a/build.gradle +++ b/build.gradle @@ -8,7 +8,7 @@ buildscript { } } dependencies { - classpath 'com.android.tools.build:gradle:0.11.+' + classpath 'com.android.tools.build:gradle:0.13.2' } } diff --git a/demo/build.gradle b/demo/build.gradle index 2771750..d9a329d 100644 --- a/demo/build.gradle +++ b/demo/build.gradle @@ -3,7 +3,7 @@ buildscript { mavenCentral() } dependencies { - classpath 'com.android.tools.build:gradle:0.11.+' + classpath 'com.android.tools.build:gradle:0.13.2' } } @@ -30,6 +30,7 @@ android { dependencies { compile 'com.android.support:appcompat-v7:19.+' - compile fileTree(dir: 'libs', include: ['*.jar']) - compile 'info.hoang8f:android-segmented:1.0.2' + compile fileTree(include: ['*.jar'], dir: 'libs') + // compile 'info.hoang8f:android-segmented:1.0.2' + compile project(':library') } diff --git a/demo/src/main/java/info/hoang8f/mymo/segmented/demo/SampleActivity.java b/demo/src/main/java/info/hoang8f/mymo/segmented/demo/SampleActivity.java index 0b8ce3f..fb391db 100644 --- a/demo/src/main/java/info/hoang8f/mymo/segmented/demo/SampleActivity.java +++ b/demo/src/main/java/info/hoang8f/mymo/segmented/demo/SampleActivity.java @@ -45,19 +45,20 @@ public View onCreateView(LayoutInflater inflater, ViewGroup container, SegmentedGroup segmented2 = (SegmentedGroup) rootView.findViewById(R.id.segmented2); segmented2.setTintColor(Color.DKGRAY); + segmented2.setPressedTintColor(Color.LTGRAY, Color.DKGRAY); SegmentedGroup segmented3 = (SegmentedGroup) rootView.findViewById(R.id.segmented3); //Tint color, and text color when checked segmented3.setTintColor(Color.parseColor("#FFD0FF3C"), Color.parseColor("#FF7B07B2")); - + segmented3.setPressedTintColor(Color.parseColor("#DDD0FF3C"), Color.parseColor("#FFD0FF3C")); SegmentedGroup segmented4 = (SegmentedGroup) rootView.findViewById(R.id.segmented4); - segmented4.setTintColor(getResources().getColor(R.color.radio_button_selected_color)); + segmented4.setTintColor(getResources().getColor(R.color.ios_color)); segmented5 = (SegmentedGroup) rootView.findViewById(R.id.segmented5); Button addBtn = (Button) rootView.findViewById(R.id.add_segmented); Button removeBtn = (Button) rootView.findViewById(R.id.remove_segmented); - //Set listencer for button + //Set listener for button addBtn.setOnClickListener(this); removeBtn.setOnClickListener(this); @@ -107,10 +108,10 @@ public void onClick(View v) { switch (v.getId()) { case R.id.add_segmented: addButton(segmented5); - return; + break; case R.id.remove_segmented: removeButton(segmented5); - return; + break; } } diff --git a/demo/src/main/res/layout/fragment_sample.xml b/demo/src/main/res/layout/fragment_sample.xml index c49dfa3..0ee95dd 100644 --- a/demo/src/main/res/layout/fragment_sample.xml +++ b/demo/src/main/res/layout/fragment_sample.xml @@ -1,188 +1,196 @@ - + android:layout_height="match_parent"> - + android:orientation="vertical" + tools:context="info.hoang8f.android.segmented.SampleActivity$PlaceholderFragment"> - + android:background="#ffffff" + android:gravity="center" + android:minHeight="80dp"> - + android:layout_margin="10dp" + app:tint_color="@color/ios_color" + android:orientation="horizontal"> - - + - + + - - - - - - + android:background="#ffb1ff69" + android:gravity="center" + android:minHeight="80dp"> - - - - - - - - - - - - + android:layout_margin="10dp" + android:orientation="horizontal"> - + + + + - + - - - - - + android:background="#FF7B07B2" + android:gravity="center" + android:minHeight="80dp"> - - - - + android:layout_margin="10dp" + android:orientation="horizontal"> - + + + + + + - + + android:layout_width="match_parent" + android:layout_height="wrap_content" + android:background="#ffffff" + android:gravity="center" + android:minHeight="80dp"> + + + + + + + + - + - + -