Project

General

Profile

« Previous | Next » 

Revision 95292d05

Added by Leszek Koltunski over 4 years ago

Prettier spinner.

View differences:

src/main/java/org/distorted/dialog/RubikDialogEffects.java
67 67
    int color  = ContextCompat.getColor(act, R.color.grey);
68 68
    LinearLayout outerLayout = new LinearLayout(act);
69 69
    LinearLayout.LayoutParams outerLayoutParams = new LinearLayout.LayoutParams(LinearLayout.LayoutParams.MATCH_PARENT,LinearLayout.LayoutParams.MATCH_PARENT, 0.5f);
70
    outerLayoutParams.topMargin    = margin;
70
    outerLayoutParams.topMargin    = index>0 ? margin : 0;
71 71
    outerLayoutParams.bottomMargin = 0;
72 72
    outerLayoutParams.leftMargin   = margin;
73 73
    outerLayoutParams.rightMargin  = margin;
......
164 164
    innerLayout2.addView(text3View);
165 165
    //////////////////////////////////////////////////////////////////
166 166
    int spinnerPadding = (int)(scale*10 + 0.5f);
167
    int spinnerMargin  = (int)(scale* 3 + 0.5f);
167 168
    LinearLayout.LayoutParams spinnerLayoutParams = new LinearLayout.LayoutParams(0,LinearLayout.LayoutParams.MATCH_PARENT,0.6f);
169
    spinnerLayoutParams.topMargin    =   spinnerMargin;
170
    spinnerLayoutParams.bottomMargin =   spinnerMargin;
171
    spinnerLayoutParams.leftMargin   =   spinnerMargin;
172
    spinnerLayoutParams.rightMargin  = 2*spinnerMargin;
168 173

  
169 174
    Spinner spinner = new Spinner(act);
170 175
    spinner.setLayoutParams(spinnerLayoutParams);
171 176
    spinner.setPadding(spinnerPadding,0,spinnerPadding,0);
177
    spinner.setBackgroundResource(R.drawable.spinner);
172 178
    spinner.setTextAlignment(View.TEXT_ALIGNMENT_CENTER);
173 179
    spinner.setId(index+BaseEffect.Type.LENGTH);
174 180
    innerLayout2.addView(spinner);
src/main/res/drawable/spinner.xml
1
<?xml version="1.0" encoding="utf-8"?>
2
<selector xmlns:android="http://schemas.android.com/apk/res/android">
3
    <item>
4
        <layer-list>
5
            <item>
6
                <shape android:shape="rectangle">
7
                    <solid android:color="@color/light_grey" />
8
                    <corners android:radius="6dip" />
9
                    <stroke
10
                        android:color="@color/grey"
11
                        android:width="2dp"/>
12
                </shape>
13
            </item>
14
            <item >
15
                <bitmap android:gravity="center_vertical|right" android:src="@drawable/spinner_arrow"/>
16
            </item>
17
        </layer-list>
18
    </item>
19
</selector>
src/main/res/layout/dialog_pattern_tab.xml
7 7

  
8 8
    <Spinner
9 9
        android:id="@+id/pattern_category_spinner"
10
        android:background="@drawable/spinner"
10 11
        android:layout_marginLeft="20dp"
11 12
        android:layout_marginRight="20dp"
12 13
        android:layout_marginTop="10dp"
src/main/res/values/colors.xml
5 5
    <color name="colorAccent">#D81B60</color>
6 6
    <color name="red">#ffff0000</color>
7 7
    <color name="grey">#ff333333</color>
8
    <color name="light_grey">#ff555555</color>
8 9
    <color name="black">#ff010101</color>
9 10
    <color name="white">#ffffffff</color>
10 11
</resources>

Also available in: Unified diff