Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 14 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -52,15 +53,28 @@ Define in xml like this and make sure that the `RadioButton`'s style is: `@style
</info.hoang8f.android.segmented.SegmentedGroup>
```

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));
Expand Down
2 changes: 1 addition & 1 deletion build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ buildscript {
}
}
dependencies {
classpath 'com.android.tools.build:gradle:0.11.+'
classpath 'com.android.tools.build:gradle:0.13.2'
}
}

Expand Down
7 changes: 4 additions & 3 deletions demo/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ buildscript {
mavenCentral()
}
dependencies {
classpath 'com.android.tools.build:gradle:0.11.+'
classpath 'com.android.tools.build:gradle:0.13.2'
}
}

Expand All @@ -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')
}
Original file line number Diff line number Diff line change
Expand Up @@ -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);

Expand Down Expand Up @@ -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;
}
}

Expand Down
Loading