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
4 changes: 2 additions & 2 deletions app/app.iml
Original file line number Diff line number Diff line change
Expand Up @@ -91,10 +91,10 @@
</content>
<orderEntry type="jdk" jdkName="Android API 23 Platform" jdkType="Android SDK" />
<orderEntry type="sourceFolder" forTests="false" />
<orderEntry type="library" exported="" name="design-23.0.1" level="project" />
<orderEntry type="library" exported="" name="appcompat-v7-23.0.1" level="project" />
<orderEntry type="library" exported="" name="butterknife-7.0.1" level="project" />
<orderEntry type="library" exported="" name="support-v4-23.0.1" level="project" />
<orderEntry type="library" exported="" name="design-23.0.1" level="project" />
<orderEntry type="library" exported="" name="appcompat-v7-23.0.1" level="project" />
<orderEntry type="library" exported="" name="support-annotations-23.0.1" level="project" />
<orderEntry type="module" module-name="library" exported="" />
</component>
Expand Down
27 changes: 10 additions & 17 deletions app/src/main/res/layout/content_main.xml
Original file line number Diff line number Diff line change
Expand Up @@ -12,15 +12,13 @@
android:paddingTop="@dimen/activity_vertical_margin"
app:layout_behavior="@string/appbar_scrolling_view_behavior"
tools:context=".MainActivity"
tools:showIn="@layout/activity_main"
>
tools:showIn="@layout/activity_main">

<android.support.v7.widget.AppCompatTextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="@string/symbolic_tick_prb_caption"
android:textSize="@dimen/sample_caption_text_size"
/>
android:textSize="@dimen/sample_caption_text_size" />

<io.techery.properratingbar.ProperRatingBar
android:layout_width="wrap_content"
Expand All @@ -33,50 +31,45 @@
app:prb_symbolicTick="$"
app:prb_symbolicTickNormalColor="@android:color/darker_gray"
app:prb_symbolicTickSelectedColor="@android:color/holo_green_dark"
app:prb_totalTicks="5"
/>
app:prb_totalTicks="5" />

<android.support.v7.widget.AppCompatTextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="@string/drawable_tick_prb_caption"
android:textSize="@dimen/sample_caption_text_size"
/>
android:textSize="@dimen/sample_caption_text_size" />

<io.techery.properratingbar.ProperRatingBar
android:id="@+id/ratingBar"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center_horizontal"
android:layout_margin="@dimen/sample_default_margin"
app:prb_clickable="true"
app:prb_defaultRating="4"
app:prb_imageSize="@dimen/sample_prb_image_size"
app:prb_tickNormalDrawable="@drawable/ic_star_normal"
app:prb_tickSelectedDrawable="@drawable/ic_star_selected"
app:prb_tickSpacing="@dimen/sample_prb_tick_spacing"
app:prb_totalTicks="7"
app:prb_clickable="true"
/>
app:prb_totalTicks="7" />

<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal"
>
android:orientation="horizontal">

<Button
android:id="@+id/getRatingButton"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="1"
android:text="@string/get_rating_button_caption"
/>
android:text="@string/get_rating_button_caption" />

<Button
android:id="@+id/setRatingButton"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="1"
android:text="@string/set_rating_button_caption"
/>
android:text="@string/set_rating_button_caption" />
</LinearLayout>
</LinearLayout>
1 change: 1 addition & 0 deletions app/src/main/res/values/dimens.xml
Original file line number Diff line number Diff line change
Expand Up @@ -8,4 +8,5 @@
<dimen name="sample_symbolic_tick_text_size">20sp</dimen>
<dimen name="sample_default_margin">16dp</dimen>
<dimen name="sample_prb_tick_spacing">5dp</dimen>
<dimen name="sample_prb_image_size">50dp</dimen>
</resources>
3 changes: 3 additions & 0 deletions library/res/values/attrs.xml
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,9 @@
<resources>
<declare-styleable name="ProperRatingBar" >

<!--Set image size Default is 15dp-->
<attr name="prb_imageSize" format="dimension"/>

<!-- Total number of ticks to show. Default is '5' -->
<attr name="prb_totalTicks" format="integer" />

Expand Down
6 changes: 5 additions & 1 deletion library/src/io/techery/properratingbar/ProperRatingBar.java
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
import android.util.AttributeSet;
import android.util.TypedValue;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ImageView;
import android.widget.LinearLayout;
import android.widget.TextView;
Expand Down Expand Up @@ -66,7 +67,7 @@ public class ProperRatingBar extends LinearLayout {
private Drawable tickNormalDrawable;
private Drawable tickSelectedDrawable;
private int tickSpacing;

private float starImageSize;
private boolean useSymbolicTick = false;
private int rating;
private RatingListener listener = null;
Expand All @@ -80,6 +81,7 @@ public ProperRatingBar(Context context, AttributeSet attrs) {
private void init(Context context, AttributeSet attrs) {
TypedArray a = context.obtainStyledAttributes(attrs, R.styleable.ProperRatingBar);
//
starImageSize = a.getDimension(R.styleable.ProperRatingBar_prb_imageSize, 15);
totalTicks = a.getInt(R.styleable.ProperRatingBar_prb_totalTicks, DF_TOTAL_TICKS);
rating = a.getInt(R.styleable.ProperRatingBar_prb_defaultRating, DF_DEFAULT_TICKS);
if (rating > totalTicks) rating = totalTicks;
Expand Down Expand Up @@ -139,6 +141,8 @@ private void addSymbolicChild(Context context, int position) {

private void addDrawableChild(Context context, int position) {
ImageView iv = new ImageView(context);
ViewGroup.LayoutParams para = new ViewGroup.LayoutParams(Math.round(starImageSize), Math.round(starImageSize));
iv.setLayoutParams(para);
iv.setPadding(tickSpacing, tickSpacing, tickSpacing, tickSpacing);
if (isClickable) {
iv.setTag(R.id.prb_child_tag_id, position);
Expand Down