Java Code Examples for android.widget.EditText#setCompoundDrawablesWithIntrinsicBounds()

The following examples show how to use android.widget.EditText#setCompoundDrawablesWithIntrinsicBounds() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: LastFragment.java    From Android-skin-support with MIT License 6 votes vote down vote up
@Nullable
@Override
public View onCreateView(LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) {
    View view = inflater.inflate(R.layout.fragment, null);
    mEdit = (EditText) view.findViewById(R.id.edit);
    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN_MR1) {
        mEdit.setCompoundDrawablesRelativeWithIntrinsicBounds(R.drawable.drawable_left_selector,
                R.drawable.drawable_top_selector,
                R.drawable.drawable_right_selector,
                R.drawable.drawable_bottom_selector);
    }
    mEdit1 = (EditText) view.findViewById(R.id.edit1);
    mEdit1.setCompoundDrawablesWithIntrinsicBounds(R.drawable.drawable_left_selector,
            R.drawable.drawable_top_selector,
            R.drawable.drawable_right_selector,
            R.drawable.drawable_bottom_selector);
    mText1 = (TextView) view.findViewById(R.id.text1);
    mText1.setCompoundDrawablesWithIntrinsicBounds(getResources().getDrawable(R.drawable.drawable_left_selector),
            getResources().getDrawable(R.drawable.drawable_top_selector),
            getResources().getDrawable(R.drawable.drawable_right_selector),
            getResources().getDrawable(R.drawable.drawable_bottom_selector));
    return view;
}
 
Example 2
Source File: LastFragment.java    From Android-skin-support with MIT License 6 votes vote down vote up
@Nullable
@Override
public View onCreateView(LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) {
    View view = inflater.inflate(R.layout.fragment, null);
    mEdit = (EditText) view.findViewById(R.id.edit);
    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN_MR1) {
        mEdit.setCompoundDrawablesRelativeWithIntrinsicBounds(R.drawable.drawable_left_selector,
                R.drawable.drawable_top_selector,
                R.drawable.drawable_right_selector,
                R.drawable.drawable_bottom_selector);
    }
    mEdit1 = (EditText) view.findViewById(R.id.edit1);
    mEdit1.setCompoundDrawablesWithIntrinsicBounds(R.drawable.drawable_left_selector,
            R.drawable.drawable_top_selector,
            R.drawable.drawable_right_selector,
            R.drawable.drawable_bottom_selector);
    mText1 = (TextView) view.findViewById(R.id.text1);
    mText1.setCompoundDrawablesWithIntrinsicBounds(getResources().getDrawable(R.drawable.drawable_left_selector),
            getResources().getDrawable(R.drawable.drawable_top_selector),
            getResources().getDrawable(R.drawable.drawable_right_selector),
            getResources().getDrawable(R.drawable.drawable_bottom_selector));
    return view;
}
 
Example 3
Source File: MainActivity.java    From FormatEditText with MIT License 6 votes vote down vote up
private void checkSimpleValid(EditText editText) {
    if (editText.length() == 0) {
        editText.setCompoundDrawablesWithIntrinsicBounds(null, null, null, null);
    } else if (editText.length() == 13) {
        editText.setCompoundDrawablesWithIntrinsicBounds(
                null,
                null,
                ContextCompat.getDrawable(MainActivity.this, R.drawable.icon_valid),
                null);
    } else {
        editText.setCompoundDrawablesWithIntrinsicBounds(
                null,
                null,
                ContextCompat.getDrawable(MainActivity.this, R.drawable.icon_invalid),
                null);
    }
}
 
Example 4
Source File: ConvKeysFragment.java    From Equate with GNU General Public License v3.0 6 votes vote down vote up
private void createCustomUnitDialog() {
	AlertDialog.Builder builder = new AlertDialog.
			  Builder(getActivity());
	builder.setTitle("Create New Unit:");

	Context context = getActivity();
	final EditText filterEditText = new EditText(context);
	final TextView textView = new TextView(context);

	filterEditText.setCompoundDrawablesWithIntrinsicBounds(R.drawable.ic_search_white, 0, 0, 0);
	filterEditText.setInputType(InputType.TYPE_CLASS_TEXT);
	filterEditText.setHint("ie Dollars");

	textView.setText("Unit Name:");

	LinearLayout layout = new LinearLayout(context);
	layout.setOrientation(LinearLayout.VERTICAL);
	layout.addView(textView);
	layout.addView(filterEditText);
	builder.setView(layout);

	builder.setNegativeButton(android.R.string.cancel, null);
	AlertDialog alert = builder.create();
	alert.show();
}
 
Example 5
Source File: FairySearchView.java    From FairySearchView with Apache License 2.0 5 votes vote down vote up
private void showOrHideSearchIcon(EditText view,boolean isShow,int imageRes){
    if(isShow){
        view.setCompoundDrawablesWithIntrinsicBounds(imageRes,0,0,0);
        view.setPadding(0,0,0,0);//清除内边距
    }else{
        view.setCompoundDrawablesWithIntrinsicBounds(0,0,0,0);
        view.setPadding(searchPaddingLeft,0,0,0);//设置左侧内边距
    }
}
 
Example 6
Source File: CommonUtils.java    From SmartChart with Apache License 2.0 4 votes vote down vote up
public static void clearFocus(EditText editText) {
    editText.setCompoundDrawablesWithIntrinsicBounds(null, null, null, null);
}