Skip to content

Commit

Permalink
Merge pull request #23 from tchar/attributes-support
Browse files Browse the repository at this point in the history
Attributes support etc.
  • Loading branch information
hoang8f committed Apr 6, 2015
2 parents d48fd36 + a917c06 commit 836dd14
Show file tree
Hide file tree
Showing 34 changed files with 206 additions and 314 deletions.
13 changes: 9 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,11 @@ android-segmented-control
Android-Segmented is a custom view for Android which is based on RadioGroup and RadioButton widget.
This implementation is inspired by [Segmented Controls](https://developer.apple.com/library/ios/documentation/userexperience/conceptual/UIKitUICatalog/UISegmentedControl.html) for iOS.

![Sample Image](https://raw.githubusercontent.com/hoang8f/android-segmented-control/master/screenshot/screenshot.png)
![Sample Image](https://github.com/tchar/android-segmented-control/blob/attributes-support/screenshot/screenshot.png)

Added support for vertical RadioGroup by [tchar](https://github.com/tchar) for vertical RadioGroup
Added support for vertical RadioGroup by [tchar](https://github.com/tchar).

![Sample Image](https://raw.githubusercontent.com/tchar/android-segmented-control/vertical-radiogroups/screenshot/screenshot2.png)
![Sample Image](https://github.com/tchar/android-segmented-control/blob/attributes-support/screenshot/screenshot2.png)

##Including in your project

Expand All @@ -33,12 +33,16 @@ Usage
Define in xml like this and make sure that the `RadioButton`'s style is: `@style/RadioButton`

```xml

<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">
android:orientation="horizontal"
segmentedgroup:border_width="2dp"
segmentedgroup:corner_radius="10dp">

<RadioButton
android:id="@+id/button21"
Expand Down Expand Up @@ -69,6 +73,7 @@ segmented3.setTintColor(Color.parseColor("#FFD0FF3C"), Color.parseColor("#FF7B07
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)

Credits
-------
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.13.2'
classpath 'com.android.tools.build:gradle:1.0.1'
}
}

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

apply plugin: 'android'
apply plugin: 'com.android.application'

android {
compileSdkVersion 19
Expand All @@ -20,7 +20,7 @@ android {
}
buildTypes {
release {
runProguard false
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.txt'
}
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,11 @@
package info.hoang8f.mymo.segmented.demo;

import android.app.Activity;
import android.graphics.Color;
import android.os.Bundle;
import android.view.View;

import info.hoang8f.android.segmented.SegmentedGroup;

/**
* Created by tchar on 6/12/2014.
Expand All @@ -12,5 +16,16 @@ public class VerticalRadioButtonsActivity extends Activity {
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_vertical_radio_buttons);
View rootView = findViewById(android.R.id.content).getRootView();

SegmentedGroup segmented2 = (SegmentedGroup) rootView.findViewById(R.id.segmented2);
segmented2.setTintColor(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"));

SegmentedGroup segmented4 = (SegmentedGroup) rootView.findViewById(R.id.segmented4);
segmented4.setTintColor(getResources().getColor(R.color.radio_button_selected_color));
}
}
17 changes: 13 additions & 4 deletions demo/src/main/res/layout/activity_vertical_radio_buttons.xml
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:segmentedgroup="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
Expand All @@ -17,7 +18,9 @@
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_margin="10dp"
android:orientation="vertical">
android:orientation="vertical"
segmentedgroup:border_width="2dp"
segmentedgroup:corner_radius="1dp">

<RadioButton
android:id="@+id/button1"
Expand All @@ -41,7 +44,9 @@
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_margin="10dp"
android:orientation="vertical">
android:orientation="vertical"
segmentedgroup:border_width="2dp"
segmentedgroup:corner_radius="0dp">

<RadioButton
android:id="@+id/button21"
Expand Down Expand Up @@ -74,7 +79,9 @@
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_margin="10dp"
android:orientation="vertical">
android:orientation="vertical"
segmentedgroup:border_width="4dp"
segmentedgroup:corner_radius="7dp">

<RadioButton
android:id="@+id/button31"
Expand Down Expand Up @@ -112,7 +119,9 @@
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_margin="10dp"
android:orientation="vertical">
android:orientation="vertical"
segmentedgroup:border_width="4dp"
segmentedgroup:corner_radius="15dp">

<RadioButton
android:id="@+id/button41"
Expand Down
16 changes: 12 additions & 4 deletions demo/src/main/res/layout/fragment_sample.xml
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
xmlns:segmentedgroup="http://schemas.android.com/apk/res-auto"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical"
Expand All @@ -17,7 +18,8 @@
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_margin="10dp"
android:orientation="horizontal">
android:orientation="horizontal"
segmentedgroup:border_width="5dp">

<RadioButton
android:id="@+id/button1"
Expand All @@ -41,7 +43,9 @@
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_margin="10dp"
android:orientation="horizontal">
android:orientation="horizontal"
segmentedgroup:border_width="4dp"
segmentedgroup:corner_radius="10dp">

<RadioButton
android:id="@+id/button21"
Expand Down Expand Up @@ -74,7 +78,9 @@
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_margin="10dp"
android:orientation="horizontal">
android:orientation="horizontal"
segmentedgroup:border_width="8dp"
segmentedgroup:corner_radius="0dp">

<RadioButton
android:id="@+id/button31"
Expand Down Expand Up @@ -112,7 +118,9 @@
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_margin="10dp"
android:orientation="horizontal">
android:orientation="horizontal"
segmentedgroup:border_width="1dp"
segmentedgroup:corner_radius="20dp">

<RadioButton
android:id="@+id/button41"
Expand Down
3 changes: 2 additions & 1 deletion demo/src/main/res/values/dimens.xml
Original file line number Diff line number Diff line change
Expand Up @@ -2,5 +2,6 @@
<!-- Default screen margins, per the Android Design guidelines. -->
<dimen name="activity_horizontal_margin">16dp</dimen>
<dimen name="activity_vertical_margin">16dp</dimen>

<dimen name="radio_button_conner_radius">5dp</dimen>
<dimen name="radio_button_stroke_border">1dp</dimen>
</resources>
2 changes: 1 addition & 1 deletion library/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ android {
}
buildTypes {
release {
runProguard false
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.txt'
}
}
Expand Down

0 comments on commit 836dd14

Please sign in to comment.