Example usage for android.view Gravity END

List of usage examples for android.view Gravity END

Introduction

In this page you can find the example usage for android.view Gravity END.

Prototype

int END

To view the source code for android.view Gravity END.

Click Source Link

Document

Push object to x-axis position at the end of its container, not changing its size.

Usage

From source file:id.co.datascrip.dtswarehousesystem.custom.StepPagerStrip.java

@Override
protected void onDraw(Canvas canvas) {
    super.onDraw(canvas);

    if (mPageCount == 0) {
        return;// w  ww .  jav  a2s.co m
    }

    float totalWidth = mPageCount * (mTabWidth + mTabSpacing) - mTabSpacing;
    float totalLeft;
    boolean fillHorizontal = false;

    switch (mGravity & Gravity.HORIZONTAL_GRAVITY_MASK) {
    case Gravity.CENTER_HORIZONTAL:
        totalLeft = (getWidth() - totalWidth) / 2;
        break;
    case Gravity.END:
        totalLeft = getWidth() - getPaddingRight() - totalWidth;
        break;
    case Gravity.FILL_HORIZONTAL:
        totalLeft = getPaddingLeft();
        fillHorizontal = true;
        break;
    default:
        totalLeft = getPaddingLeft();
    }

    switch (mGravity & Gravity.VERTICAL_GRAVITY_MASK) {
    case Gravity.CENTER_VERTICAL:
        mTempRectF.top = (int) (getHeight() - mTabHeight) / 2;
        break;
    case Gravity.BOTTOM:
        mTempRectF.top = getHeight() - getPaddingBottom() - mTabHeight;
        break;
    default:
        mTempRectF.top = getPaddingTop();
    }

    mTempRectF.bottom = mTempRectF.top + mTabHeight;

    float tabWidth = mTabWidth;
    if (fillHorizontal) {
        tabWidth = (getWidth() - getPaddingRight() - getPaddingLeft() - (mPageCount - 1) * mTabSpacing)
                / mPageCount;
    }

    for (int i = 0; i < mPageCount; i++) {
        mTempRectF.left = totalLeft + (i * (tabWidth + mTabSpacing));
        mTempRectF.right = mTempRectF.left + tabWidth;
        canvas.drawRect(mTempRectF,
                i < mCurrentPage ? mPrevTabPaint
                        : (i > mCurrentPage ? mNextTabPaint
                                : (i == mPageCount - 1 ? mSelectedLastTabPaint : mSelectedTabPaint)));
    }
}

From source file:com.androidzeitgeist.webcards.overlay.HandleView.java

void addToRoot() {
    setVisibility(View.VISIBLE);/* www  .  j ava2  s . c o  m*/

    if (isShown()) {
        return;
    }

    int size = getResources().getDimensionPixelSize(R.dimen.overlay_button_size);

    WindowManager.LayoutParams layoutParams = new WindowManager.LayoutParams(size, size,
            WindowManager.LayoutParams.TYPE_PHONE,
            WindowManager.LayoutParams.FLAG_NOT_TOUCH_MODAL | WindowManager.LayoutParams.FLAG_NOT_FOCUSABLE
                    | WindowManager.LayoutParams.FLAG_LAYOUT_IN_SCREEN
                    | WindowManager.LayoutParams.FLAG_LAYOUT_NO_LIMITS
                    | WindowManager.LayoutParams.FLAG_HARDWARE_ACCELERATED,
            PixelFormat.TRANSLUCENT);

    layoutParams.gravity = Gravity.CENTER_HORIZONTAL | Gravity.END;
    layoutParams.x = openOffsetX;

    try {
        windowManager.addView(this, layoutParams);
    } catch (final SecurityException | WindowManager.BadTokenException e) {
        // We do not have the permission to add a view to the window ("draw over other apps")
        Toast.makeText(getContext(), R.string.toast_missing_permission, Toast.LENGTH_SHORT).show();
    }
}

From source file:org.odk.collect.android.fragments.AppListFragment.java

public Boolean getDrawerStatus() {
    return drawerLayout != null && drawerLayout.isDrawerOpen(Gravity.END);
}

From source file:com.klinker.android.twitter.listeners.InteractionClickListener.java

@Override
public void onItemClick(AdapterView<?> adapterView, View view, int i, long l) {
    HoloTextView title = (HoloTextView) view.findViewById(R.id.title);
    String mTitle = title.getText().toString();

    HoloTextView text = (HoloTextView) view.findViewById(R.id.text);
    String mText = text.getText().toString();

    // get the datasource ready to read/write
    InteractionsDataSource data = InteractionsDataSource.getInstance(context);

    if (mTitle.contains(context.getResources().getString(R.string.mentioned_by))) { // this is a mention
        if (MainDrawerArrayAdapter.current < 3) {
            new Handler().postDelayed(new Runnable() {
                @Override//w  ww . j  a  v a 2 s.com
                public void run() {
                    try {
                        drawer.closeDrawer(Gravity.END);
                    } catch (Exception e) {
                        // landscape mode
                    }
                }
            }, 300);

            viewPager.setCurrentItem((1 + extraPages), true);
        } else {
            final int pos = i;
            try {
                drawer.closeDrawer(Gravity.END);
            } catch (Exception e) {
                // landscape mode
            }
            new Thread(new Runnable() {
                @Override
                public void run() {
                    Intent intent = new Intent(context, MainActivity.class);
                    intent.setFlags(Intent.FLAG_ACTIVITY_NO_ANIMATION);
                    intent.putExtra("page_to_open", (1 + extraPages));
                    intent.putExtra("from_drawer", true);

                    sharedPreferences.edit().putBoolean("should_refresh", false).commit();

                    try {
                        Thread.sleep(400);
                    } catch (Exception e) {

                    }

                    try {
                        context.startActivity(intent);
                        ((Activity) context).overridePendingTransition(0, 0);
                        ((Activity) context).finish();
                    } catch (Exception e) {
                        e.printStackTrace();
                    }

                }
            }).start();
        }
    } else if (mTitle.contains(context.getResources().getString(R.string.retweeted))
            || mTitle.contains(context.getResources().getString(R.string.favorited))
            || mTitle.contains(context.getResources().getString(R.string.new_favorites))
            || mTitle.contains(context.getResources().getString(R.string.new_retweets))) { // it is a retweet or favorite

        try {
            drawer.closeDrawer(Gravity.END);
        } catch (Exception e) {
            // landscape mode
        }

        // open up the dialog with the users that retweeted it

        final String[] fItems = data
                .getUsers(sharedPreferences.getInt("current_account", 1), i,
                        DrawerActivity.oldInteractions.getText().toString()
                                .equals(context.getResources().getString(R.string.old_interactions)))
                .split(" ");

        LayoutInflater factory = LayoutInflater.from(context);
        View content = factory.inflate(R.layout.interaction_dialog, null);

        TextView textView = (TextView) content.findViewById(R.id.text);
        textView.setText(mText);

        ListView lv = (ListView) content.findViewById(R.id.list);
        lv.setAdapter(new ArrayAdapter<String>(context, android.R.layout.simple_selectable_list_item, fItems));
        lv.setOnItemClickListener(new AdapterView.OnItemClickListener() {
            @Override
            public void onItemClick(AdapterView<?> adapterView, View view, int item, long l) {
                String touched = fItems[item];

                Intent user = new Intent(context, ProfilePager.class);
                user.putExtra("screenname", touched.replace("@", "").replace(" ", ""));
                user.putExtra("proPic", "");
                context.startActivity(user);
            }
        });

        AlertDialog.Builder builder = new AlertDialog.Builder(context);
        builder.setView(content);

        AlertDialog alert = builder.create();
        alert.show();
    } else if (mTitle.contains(context.getResources().getString(R.string.followed))) { // someone new followed you

        try {
            drawer.closeDrawer(Gravity.END);
        } catch (Exception e) {
            // landscape mode
        }

        // a new follower, open up the followers profile
        String username = mTitle.substring(mTitle.indexOf("@") + 1, mTitle.indexOf(" "));

        Intent user = new Intent(context, ProfilePager.class);
        user.putExtra("screenname", username);
        user.putExtra("proPic", "");
        context.startActivity(user);
    } else if (mTitle.contains(context.getResources().getString(R.string.tweeted))) {
        try {
            drawer.closeDrawer(Gravity.END);
        } catch (Exception e) {
            // landscape mode
        }

        // a new follower, open up the followers profile
        String username = mTitle.substring(mTitle.indexOf("@") + 1, mTitle.indexOf(" "));

        Intent user = new Intent(context, ProfilePager.class);
        user.putExtra("screenname", username);
        user.putExtra("proPic", "");
        context.startActivity(user);
    }

    // mark it read in the sql database
    data.markRead(sharedPreferences.getInt("current_account", 1), i);

    // tell the system to refresh the notifications when the user opens the drawer again
    sharedPreferences.edit().putBoolean("new_notification", true).commit();
}

From source file:uk.ac.horizon.artcodes.fragment.ExperienceLibraryFragment.java

@NonNull
@Override/* w w w  .j  av a 2  s. co m*/
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
    ListBinding binding = ListBinding.inflate(inflater, container, false);
    adapter = new ExperienceSortedListAdapter(getActivity(), getServer());
    adapter.enableFABPadding();
    adapter.setEmptyIcon(R.drawable.ic_folder_144dp);
    adapter.setEmptyMessage(getString(R.string.empty));
    adapter.setEmptyDetail(getString(R.string.emptyHint));
    binding.setAdapter(adapter);

    final FloatingActionButton fab = new FloatingActionButton(getContext());
    fab.setImageDrawable(getTintedDrawable(R.drawable.ic_add_24dp, Color.WHITE));
    //fab.setBackgroundColor(ContextCompat.getColor(getContext(), R.color.apptheme_accent));
    fab.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View v) {
            ExperienceEditActivity.start(getActivity(), new Experience(), account);
        }
    });
    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
        fab.setElevation(4);
    }

    final int spacing = getResources().getDimensionPixelSize(R.dimen.padding);
    final FrameLayout.LayoutParams layoutParams = new FrameLayout.LayoutParams(
            ViewGroup.LayoutParams.WRAP_CONTENT, ViewGroup.LayoutParams.WRAP_CONTENT);
    layoutParams.gravity = Gravity.BOTTOM | Gravity.END;
    layoutParams.setMargins(spacing, spacing, spacing, spacing);

    fab.setLayoutParams(layoutParams);

    ((ViewGroup) binding.getRoot()).addView(fab);

    return binding.getRoot();
}

From source file:azad.hallaji.farzad.com.masirezendegi.PageVirayesh.java

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_page_virayesh);

    Fabric.with(this, new Crashlytics());

    TextView virayeshTextinToolbar = (TextView) findViewById(R.id.virayeshTextinToolbar);
    final TextView zaxireTextinToolbar = (TextView) findViewById(R.id.zaxireTextinToolbar);
    init();//from  w w w. j  a v  a2s  .co m
    ableall(false);

    drawer = (DrawerLayout) findViewById(R.id.drawer_layout);

    NavigationView navigationView = (NavigationView) findViewById(R.id.nav_view);
    navigationView.setNavigationItemSelectedListener(this);

    ImageView imageView = (ImageView) findViewById(R.id.menuButton);
    imageView.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View v) {

            drawer.openDrawer(Gravity.END);

        }
    });

    if (GlobalVar.getUserType().equals("adviser") || GlobalVar.getUserType().equals("user")) {

        Menu nav_Menu = navigationView.getMenu();
        nav_Menu.findItem(R.id.nav_marakez).setVisible(true);
        nav_Menu.findItem(R.id.nav_profile).setVisible(true);
        nav_Menu.findItem(R.id.nav_login).setVisible(false);
        nav_Menu.findItem(R.id.nav_moshaverin).setVisible(true);
        nav_Menu.findItem(R.id.nav_porseshha).setVisible(true);
        nav_Menu.findItem(R.id.nav_logout).setVisible(true);

    } else {

        Menu nav_Menu = navigationView.getMenu();
        nav_Menu.findItem(R.id.nav_marakez).setVisible(true);
        nav_Menu.findItem(R.id.nav_profile).setVisible(false);
        nav_Menu.findItem(R.id.nav_login).setVisible(true);
        nav_Menu.findItem(R.id.nav_moshaverin).setVisible(true);
        nav_Menu.findItem(R.id.nav_porseshha).setVisible(true);
        nav_Menu.findItem(R.id.nav_logout).setVisible(false);
    }

    final ImageView imageView1 = (ImageView) findViewById(R.id.onclickeasadinchimastanxanim);
    imageView1.setVisibility(View.GONE);

    if (isOnline()) {
        setAlage();

        if (GlobalVar.getUserType().equals("adviser")) {

            virayeshTextinToolbar.setOnClickListener(new View.OnClickListener() {
                @Override
                public void onClick(View v) {
                    ableall(true);
                    sihhhhh1.setVisibility(View.VISIBLE);
                    sihhhhh2.setVisibility(View.VISIBLE);
                    imageView1.setOnClickListener(new View.OnClickListener() {
                        @Override
                        public void onClick(View v) {
                            Intent pickPhoto = new Intent(Intent.ACTION_PICK,
                                    android.provider.MediaStore.Images.Media.EXTERNAL_CONTENT_URI);
                            startActivityForResult(pickPhoto, 1);//one can be replaced with any action code
                        }
                    });
                    zaxireTextinToolbar.setOnClickListener(new View.OnClickListener() {
                        @Override
                        public void onClick(View v) {
                            postgetData();
                        }
                    });
                }
            });

            imageView1.setVisibility(View.VISIBLE);
            barchasbEdit.setVisibility(View.VISIBLE);
            costperminEdit.setVisibility(View.VISIBLE);
            maxtimeEdit.setVisibility(View.VISIBLE);
            sexEdit.setVisibility(View.VISIBLE);
            dialtecEdit.setVisibility(View.VISIBLE);
            aboutmeEdit.setVisibility(View.VISIBLE);

        } else if (GlobalVar.getUserType().equals("user")) {

            virayeshTextinToolbar.setOnClickListener(new View.OnClickListener() {
                @Override
                public void onClick(View v) {

                    TextView textView = (TextView) findViewById(R.id.sihhhhh1);
                    TextView textView2 = (TextView) findViewById(R.id.sihhhhh2);
                    textView.setVisibility(View.GONE);
                    textView2.setVisibility(View.GONE);
                    imageView1.setVisibility(View.VISIBLE);
                    boolean b = false;
                    sihhhhh1.setVisibility(View.GONE);
                    sihhhhh2.setVisibility(View.GONE);
                    namexanivadeEdit.setEnabled(!b);
                    shomareteleEdit.setEnabled(!b);
                    emailEdit.setEnabled(!b);
                    barchasbEdit.setVisibility(View.GONE);
                    costperminEdit.setVisibility(View.GONE);
                    maxtimeEdit.setVisibility(View.GONE);
                    sexEdit.setVisibility(View.GONE);
                    dialtecEdit.setVisibility(View.GONE);
                    aboutmeEdit.setVisibility(View.GONE);

                    imageView1.setOnClickListener(new View.OnClickListener() {
                        @Override
                        public void onClick(View v) {
                            Intent pickPhoto = new Intent(Intent.ACTION_PICK,
                                    android.provider.MediaStore.Images.Media.EXTERNAL_CONTENT_URI);
                            startActivityForResult(pickPhoto, 1);//one can be replaced with any action code
                        }
                    });
                    zaxireTextinToolbar.setOnClickListener(new View.OnClickListener() {
                        @Override
                        public void onClick(View v) {
                            postgetData();
                        }
                    });
                }
            });
        }
    } else {
        Toast.makeText(getApplicationContext(), "Network isn't available", Toast.LENGTH_LONG).show();
    }
}

From source file:org.mdc.chess.SeekBarPreference.java

@Override
protected View onCreateView(ViewGroup parent) {
    TextView name = new TextView(getContext());
    name.setText(getTitle());/* ww  w  .jav  a  2 s.c o  m*/
    //name.setTextAppearance(getContext(), android.R.style.TextAppearance_Large);
    TextViewCompat.setTextAppearance(name, android.R.style.TextAppearance_Large);
    name.setGravity(Gravity.START);
    LinearLayout.LayoutParams lp = new LinearLayout.LayoutParams(LinearLayout.LayoutParams.WRAP_CONTENT,
            LinearLayout.LayoutParams.WRAP_CONTENT);
    lp.gravity = Gravity.START;
    lp.weight = 1.0f;
    name.setLayoutParams(lp);

    currValBox = new TextView(getContext());
    currValBox.setTextSize(12);
    currValBox.setTypeface(Typeface.MONOSPACE, Typeface.ITALIC);
    currValBox.setPadding(2, 5, 0, 0);
    currValBox.setText(valToString());
    lp = new LinearLayout.LayoutParams(LinearLayout.LayoutParams.WRAP_CONTENT,
            LinearLayout.LayoutParams.WRAP_CONTENT);
    lp.gravity = Gravity.CENTER;
    currValBox.setLayoutParams(lp);

    LinearLayout row1 = new LinearLayout(getContext());
    row1.setOrientation(LinearLayout.HORIZONTAL);
    row1.addView(name);
    row1.addView(currValBox);

    final SeekBar bar = new SeekBar(getContext());
    bar.setMax(maxValue);
    bar.setProgress(currVal);
    bar.setOnSeekBarChangeListener(this);
    lp = new LinearLayout.LayoutParams(LinearLayout.LayoutParams.MATCH_PARENT,
            LinearLayout.LayoutParams.WRAP_CONTENT);
    lp.gravity = Gravity.END;
    bar.setLayoutParams(lp);

    CharSequence summaryCharSeq = getSummary();
    boolean haveSummary = (summaryCharSeq != null) && (summaryCharSeq.length() > 0);
    TextView summary = null;
    if (haveSummary) {
        summary = new TextView(getContext());
        summary.setText(getSummary());
        //            summary.setTextAppearance(getContext(), android.R.style.TextAppearance_Large);
        summary.setGravity(Gravity.START);
        lp = new LinearLayout.LayoutParams(LinearLayout.LayoutParams.WRAP_CONTENT,
                LinearLayout.LayoutParams.WRAP_CONTENT);
        lp.gravity = Gravity.START;
        lp.weight = 1.0f;
        summary.setLayoutParams(lp);
    }

    LinearLayout layout = new LinearLayout(getContext());
    layout.setPadding(25, 5, 25, 5);
    layout.setOrientation(LinearLayout.VERTICAL);
    layout.addView(row1);
    layout.addView(bar);
    if (summary != null) {
        layout.addView(summary);
    }
    layout.setId(android.R.id.widget_frame);

    currValBox.setOnClickListener(new OnClickListener() {
        @Override
        public void onClick(View v) {
            View content = View.inflate(SeekBarPreference.this.getContext(), R.layout.select_percentage, null);
            final AlertDialog.Builder builder = new AlertDialog.Builder(SeekBarPreference.this.getContext());
            builder.setView(content);
            String title = "";
            String key = getKey();
            if (key.equals("strength")) {
                title = getContext().getString(R.string.edit_strength);
            } else if (key.equals("bookRandom")) {
                title = getContext().getString(R.string.edit_randomization);
            }
            builder.setTitle(title);
            final EditText valueView = (EditText) content.findViewById(R.id.selpercentage_number);
            valueView.setText(currValBox.getText().toString().replaceAll("%", "").replaceAll(",", "."));
            final Runnable selectValue = new Runnable() {
                public void run() {
                    try {
                        String txt = valueView.getText().toString();
                        int value = (int) (Double.parseDouble(txt) * 10 + 0.5);
                        if (value < 0)
                            value = 0;
                        if (value > maxValue)
                            value = maxValue;
                        onProgressChanged(bar, value, false);
                    } catch (NumberFormatException ignored) {

                    }
                }
            };
            valueView.setOnKeyListener(new OnKeyListener() {
                public boolean onKey(View v, int keyCode, KeyEvent event) {
                    if ((event.getAction() == KeyEvent.ACTION_DOWN) && (keyCode == KeyEvent.KEYCODE_ENTER)) {
                        selectValue.run();
                        return true;
                    }
                    return false;
                }
            });
            builder.setPositiveButton("Ok", new Dialog.OnClickListener() {
                public void onClick(DialogInterface dialog, int which) {
                    selectValue.run();
                }
            });
            builder.setNegativeButton("Cancel", null);

            builder.create().show();
        }
    });

    return layout;
}

From source file:com.gdgdevfest.android.apps.devfestbcn.ui.tablet.MapMultiPaneActivity.java

@Override
public void onConfigurationChanged(Configuration newConfig) {
    super.onConfigurationChanged(newConfig);
    boolean landscape = (newConfig.orientation == Configuration.ORIENTATION_LANDSCAPE);

    LinearLayout spacerView = (LinearLayout) findViewById(R.id.map_detail_spacer);
    spacerView.setOrientation(landscape ? LinearLayout.HORIZONTAL : LinearLayout.VERTICAL);
    spacerView.setGravity(landscape ? Gravity.END : Gravity.BOTTOM);

    View popupView = findViewById(R.id.map_detail_popup);
    LinearLayout.LayoutParams popupLayoutParams = (LinearLayout.LayoutParams) popupView.getLayoutParams();
    popupLayoutParams.width = landscape ? 0 : ViewGroup.LayoutParams.MATCH_PARENT;
    popupLayoutParams.height = landscape ? ViewGroup.LayoutParams.MATCH_PARENT : 0;
    popupView.setLayoutParams(popupLayoutParams);

    popupView.requestLayout();//from  w  ww  . ja  v  a 2s  .c  o m

    updateMapPadding();
}

From source file:org.odk.collect.android.activities.AppListActivity.java

private void initToolbar() {
    toolbar = (Toolbar) findViewById(R.id.toolbar);
    toolbar.inflateMenu(R.menu.menu);/*from w ww  .  j av  a2s. co  m*/

    toolbar.findViewById(R.id.menu_sort).setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View v) {
            if (drawerLayout.isDrawerOpen(Gravity.END)) {
                drawerLayout.closeDrawer(Gravity.END);
            } else {
                Collect.getInstance().hideKeyboard(inputSearch);
                drawerLayout.openDrawer(Gravity.END);
            }
        }
    });

    toolbar.findViewById(R.id.menu_filter).setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View v) {
            if (searchBoxLayout.getVisibility() == View.GONE) {
                showSearchBox();
            } else {
                hideSearchBox();
            }
        }
    });

    if (!hasHardwareMenu) {
        setSupportActionBar(toolbar);
    }
}

From source file:org.dalol.orthodoxmezmurmedia.utilities.widgets.RecyclerViewFastIndexer.java

protected void init(Context context) {
    if (isInitialized)
        return;/*from  ww w  .  j a  va 2 s  .c  o m*/
    isInitialized = true;
    setOrientation(HORIZONTAL);
    setClipChildren(false);
    setWillNotDraw(false);

    bubble = new TextView(context);
    bubble.setTextColor(Color.WHITE);
    bubble.setTextSize(48);

    GradientDrawable bubbleDrawable = new GradientDrawable();
    bubbleDrawable.setColor(0xFFce891e);
    bubbleDrawable.setSize(getCustomSize(88), getCustomSize(88));
    bubbleDrawable.setCornerRadii(new float[] { getCustomSize(44), getCustomSize(44), getCustomSize(44),
            getCustomSize(44), 0, 0, getCustomSize(44), getCustomSize(44) });

    bubble.setBackgroundDrawable(bubbleDrawable);

    //bubble.setBackgroundResource(R.drawable.recycler_view_fast_scroller__bubble);
    bubble.setGravity(Gravity.CENTER);

    LayoutParams params = new LayoutParams(ViewGroup.LayoutParams.WRAP_CONTENT,
            ViewGroup.LayoutParams.WRAP_CONTENT);
    params.gravity = Gravity.RIGHT | Gravity.END;

    addView(bubble, params);

    if (bubble != null)
        bubble.setVisibility(INVISIBLE);

    handle = new ImageView(context);
    //handle.setBackgroundResource(R.drawable.recycler_view_fast_scroller__handle);

    GradientDrawable drawable = new GradientDrawable();
    drawable.setShape(GradientDrawable.RECTANGLE);
    drawable.setSize(getCustomSize(4), getCustomSize(35));
    drawable.setColor(0xFFce891e);
    drawable.setCornerRadius(getCustomSize(5));

    GradientDrawable drawable2 = new GradientDrawable();
    drawable2.setShape(GradientDrawable.RECTANGLE);
    drawable2.setSize(getCustomSize(4), getCustomSize(35));
    drawable2.setColor(0xFFf3a124);
    drawable2.setCornerRadius(getCustomSize(5));

    StateListDrawable states = new StateListDrawable();
    states.addState(new int[] { android.R.attr.state_selected }, drawable);
    states.addState(new int[] {}, drawable2);

    handle.setBackgroundDrawable(states);

    LayoutParams params2 = new LayoutParams(ViewGroup.LayoutParams.WRAP_CONTENT,
            ViewGroup.LayoutParams.WRAP_CONTENT);

    int dimension = getCustomSize(3);

    int doubleDimension = dimension * 2;
    params2.leftMargin = doubleDimension;
    params2.rightMargin = doubleDimension;

    handle.setPadding(dimension, 0, dimension, 0);
    handle.setOnFocusChangeListener(new OnFocusChangeListener() {
        @Override
        public void onFocusChange(View v, boolean hasFocus) {
            if (hasFocus) {
                v.setBackgroundColor(Color.parseColor("#00891e"));
            } else {
                v.setBackgroundColor(Color.parseColor("#44891e"));
            }
        }
    });

    addView(handle, params2);

}