Skip to content

Commit

Permalink
make hint in dropdown rtl
Browse files Browse the repository at this point in the history
  • Loading branch information
aliab committed Jan 22, 2017
1 parent 902042b commit 6756202
Show file tree
Hide file tree
Showing 6 changed files with 31 additions and 2 deletions.
2 changes: 1 addition & 1 deletion library/src/main/java/ir/hamsaa/RtlMaterialSpinner.java
Original file line number Diff line number Diff line change
Expand Up @@ -795,7 +795,7 @@ private View buildView(int position, View convertView, ViewGroup parent, boolean
private View getHintView(final View convertView, final ViewGroup parent, final boolean isDropDownView) {

final LayoutInflater inflater = LayoutInflater.from(mContext);
final int resid = isDropDownView ? android.R.layout.simple_spinner_dropdown_item : android.R.layout.simple_spinner_item;
final int resid = R.layout.item;
final TextView textView = (TextView) inflater.inflate(resid, parent, false);
textView.setText(hint);
textView.setTextColor(RtlMaterialSpinner.this.isEnabled() ? hintColor : disabledColor);
Expand Down
12 changes: 12 additions & 0 deletions library/src/main/res/drawable-v21/touchable_background.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
<?xml version="1.0" encoding="utf-8"?>
<ripple xmlns:android="http://schemas.android.com/apk/res/android"
android:color="@android:color/darker_gray">

<!-- when clicked -->
<item
android:id="@android:id/mask"
android:drawable="@android:color/darker_gray" />

<!-- normal state -->
<item android:drawable="@android:color/transparent" />
</ripple>
5 changes: 5 additions & 0 deletions library/src/main/res/drawable/touchable_background.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
<?xml version="1.0" encoding="utf-8"?>
<selector xmlns:android="http://schemas.android.com/apk/res/android">
<item android:drawable="@android:color/darker_gray" android:state_pressed="true" />
<item android:drawable="@android:color/transparent" />
</selector>
12 changes: 12 additions & 0 deletions library/src/main/res/layout/item.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
<TextView xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:id="@android:id/text1"
style="?android:attr/spinnerItemStyle"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:ellipsize="marquee"
android:gravity="start"
android:maxLines="1"
android:padding="8dp"
android:textAlignment="inherit"
tools:text="test" />
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ protected void onCreate(Bundle savedInstanceState) {


adapter = new ArrayAdapter<>(this, android.R.layout.simple_spinner_item, ITEMS);
adapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item);
adapter.setDropDownViewResource(fr.hamsaa.materialspinner.R.layout.item);

initSpinnerHintAndFloatingLabel();
initSpinnerNoHintNoFloatingLabel();
Expand Down
Binary file added screenshots/.DS_Store
Binary file not shown.

0 comments on commit 6756202

Please sign in to comment.