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

The following examples show how to use android.widget.EditText#setTextColor() . 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: HyperTextEditor.java    From YCCustomText with Apache License 2.0 6 votes vote down vote up
/**
 * 添加生成文本输入框
 * @param hint								内容
 * @param paddingTop						到顶部高度
 * @return
 */
private EditText createEditText(String hint, int paddingTop) {
	EditText editText = new DeletableEditText(getContext());
	LayoutParams layoutParams = new LayoutParams(LayoutParams.MATCH_PARENT, LayoutParams.WRAP_CONTENT);
	editText.setLayoutParams(layoutParams);
	editText.setTextSize(16);
	editText.setTextColor(Color.parseColor("#616161"));
	editText.setCursorVisible(true);
	editText.setBackground(null);
	editText.setOnKeyListener(keyListener);
	editText.setOnFocusChangeListener(focusListener);
	editText.addTextChangedListener(textWatcher);
	editText.setTag(viewTagIndex++);
	editText.setPadding(editNormalPadding, paddingTop, editNormalPadding, paddingTop);
	editText.setHint(hint);
	editText.setTextSize(TypedValue.COMPLEX_UNIT_PX, rtTextSize);
	editText.setTextColor(rtTextColor);
	editText.setHintTextColor(rtHintTextColor);
	editText.setLineSpacing(rtTextLineSpace, 1.0f);
	HyperLibUtils.setCursorDrawableColor(editText, cursorColor);
	return editText;
}
 
Example 2
Source File: SlideTabsActivity.java    From GPS2SMS with GNU General Public License v3.0 6 votes vote down vote up
protected void AdjustAddDialogColors(View layout) {
    // Only for Android LOWER than 3.0 !
    // Hack for lower Android versions to make text visible
    // Dialog background is DIFFERENT in Android 2.1 and Android 2.3
    // That's why we use gray color everywhere for Android < 3.0
    if (Build.VERSION.SDK_INT < Build.VERSION_CODES.HONEYCOMB) {

        TextView tv1 = (TextView) layout.findViewById(R.id.textView1);
        TextView tv2 = (TextView) layout.findViewById(R.id.textView2);
        TextView tv3 = (TextView) layout.findViewById(R.id.textView3);
        EditText et1 = (EditText) layout.findViewById(R.id.point_name);
        EditText et2 = (EditText) layout.findViewById(R.id.point_la);
        EditText et3 = (EditText) layout.findViewById(R.id.point_lo);

        tv1.setTextColor(Color.parseColor("#9E9E9E"));
        tv2.setTextColor(Color.parseColor("#9E9E9E"));
        tv3.setTextColor(Color.parseColor("#9E9E9E"));
        et1.setTextColor(Color.parseColor("#9E9E9E"));
        et2.setTextColor(Color.parseColor("#9E9E9E"));
        et3.setTextColor(Color.parseColor("#9E9E9E"));
        et1.setHintTextColor(Color.parseColor("#9E9E9E"));
        et2.setHintTextColor(Color.parseColor("#9E9E9E"));
        et3.setHintTextColor(Color.parseColor("#9E9E9E"));
    }
}
 
Example 3
Source File: AlertDialogsHelper.java    From leafpicrevived with GNU General Public License v3.0 5 votes vote down vote up
public static AlertDialog getInsertTextDialog(ThemedActivity activity, EditText editText, @StringRes int title) {

        AlertDialog.Builder dialogBuilder = new AlertDialog.Builder(activity, activity.getDialogStyle());
        View dialogLayout = activity.getLayoutInflater().inflate(com.alienpants.leafpicrevived.R.layout.dialog_insert_text, null);
        TextView textViewTitle = dialogLayout.findViewById(R.id.rename_title);

        ((CardView) dialogLayout.findViewById(com.alienpants.leafpicrevived.R.id.dialog_chose_provider_title)).setCardBackgroundColor(activity.getCardBackgroundColor());
        textViewTitle.setBackgroundColor(activity.getPrimaryColor());
        textViewTitle.setText(title);
        ThemeHelper.setCursorColor(editText, activity.getTextColor());

        FrameLayout.LayoutParams layoutParams = new FrameLayout.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.WRAP_CONTENT);
        editText.setLayoutParams(layoutParams);
        editText.setSingleLine(true);
        editText.getBackground().mutate().setColorFilter(activity.getTextColor(), PorterDuff.Mode.SRC_IN);
        editText.setTextColor(activity.getTextColor());

        try {
            Field f = TextView.class.getDeclaredField("mCursorDrawableRes");
            f.setAccessible(true);
            f.set(editText, null);
        } catch (Exception ignored) {
        }

        ((RelativeLayout) dialogLayout.findViewById(com.alienpants.leafpicrevived.R.id.container_edit_text)).addView(editText);

        dialogBuilder.setView(dialogLayout);
        return dialogBuilder.create();
    }
 
Example 4
Source File: OEditTextField.java    From hr with GNU Affero General Public License v3.0 5 votes vote down vote up
public void initControl() {
    // Creating control
    LayoutParams params = new LayoutParams(LayoutParams.MATCH_PARENT,
            LayoutParams.WRAP_CONTENT);
    removeAllViews();
    setOrientation(VERTICAL);
    if (mEditable) {
        edtText = new EditText(mContext);
        edtText.setTypeface(OControlHelper.lightFont());
        edtText.setLayoutParams(params);
        edtText.setBackgroundColor(Color.TRANSPARENT);
        edtText.setPadding(0, 10, 10, 10);
        edtText.setHint(getLabel());
        edtText.setOnFocusChangeListener(this);
        if (textSize > -1) {
            edtText.setTextSize(TypedValue.COMPLEX_UNIT_PX, textSize);
        }
        if (appearance > -1) {
            edtText.setTextAppearance(mContext, appearance);
        }
        edtText.setTextColor(textColor);
        addView(edtText);
    } else {
        txvText = new TextView(mContext);
        txvText.setTypeface(OControlHelper.lightFont());
        txvText.setLayoutParams(params);
        txvText.setBackgroundColor(Color.TRANSPARENT);
        txvText.setPadding(0, 10, 10, 10);
        if (textSize > -1) {
            txvText.setTextSize(TypedValue.COMPLEX_UNIT_PX, textSize);
        }
        if (appearance > -1) {
            txvText.setTextAppearance(mContext, appearance);
        }
        txvText.setTextColor(textColor);
        addView(txvText);
    }
}
 
Example 5
Source File: GeocodingBaseActivity.java    From mobile-android-samples with BSD 3-Clause "New" or "Revised" License 5 votes vote down vote up
@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);

    inputField = new EditText(this);
    inputField.setTextColor(Color.WHITE);
    inputField.setBackgroundColor(Colors.DARK_TRANSPARENT_GRAY);
    inputField.setHint("Type address...");
    inputField.setHintTextColor(Color.LTGRAY);
    inputField.setSingleLine();
    inputField.setImeOptions(EditorInfo.IME_ACTION_DONE);

    int totalWidth = getResources().getDisplayMetrics().widthPixels;
    int padding = (int)(5 * getResources().getDisplayMetrics().density);

    int width = totalWidth - 2 * padding;
    int height = (int)(45 * getResources().getDisplayMetrics().density);

    RelativeLayout.LayoutParams parameters = new RelativeLayout.LayoutParams(width, height);
    parameters.setMargins(padding, padding, 0, 0);
    addContentView(inputField, parameters);

    resultTable = new ListView(this);
    resultTable.setBackgroundColor(Colors.LIGHT_TRANSPARENT_GRAY);

    height = (int)(200 * getResources().getDisplayMetrics().density);

    parameters = new RelativeLayout.LayoutParams(width, height);
    parameters.setMargins(padding, 2 * padding + inputField.getLayoutParams().height, 0, 0);

    addContentView(resultTable, parameters);

    adapter = new GeocodingResultAdapter(this);
    adapter.width = width;
    resultTable.setAdapter(adapter);

    hideTable();
}
 
Example 6
Source File: PinViewBaseHelper.java    From nono-android with GNU General Public License v3.0 5 votes vote down vote up
/**
 * Set a PinBox with all attributes
 *
 * @param editText to set attributes
 */
private void setStylePinBox(EditText editText) {
    editText.setFilters(new InputFilter[]{new InputFilter.LengthFilter(mNumberCharacters)});

    if (mMaskPassword) {
        editText.setTransformationMethod(PasswordTransformationMethod.getInstance());
    }
    else{
        editText.setTransformationMethod(HideReturnsTransformationMethod.getInstance());
    }

    if (mNativePinBox) {
        if (android.os.Build.VERSION.SDK_INT < android.os.Build.VERSION_CODES.JELLY_BEAN) {
            //noinspection deprecation
            editText.setBackgroundDrawable(new EditText(getContext()).getBackground());
        } else {
            editText.setBackground(new EditText(getContext()).getBackground());
        }
    } else {
        editText.setBackgroundResource(mCustomDrawablePinBox);
    }

    if (mColorTextPinBoxes != PinViewSettings.DEFAULT_TEXT_COLOR_PIN_BOX) {
        editText.setTextColor(mColorTextPinBoxes);
    }
    editText.setTextSize(PinViewUtils.convertPixelToDp(getContext(), mTextSizePinBoxes));
}
 
Example 7
Source File: PassportActivity.java    From YiBo with Apache License 2.0 5 votes vote down vote up
private void initCompoments() {
	LinearLayout llRoot = (LinearLayout)findViewById(R.id.llRoot);
   	LinearLayout llHeaderBase = (LinearLayout)findViewById(R.id.llHeaderBase);
   	LinearLayout llTabHeader = (LinearLayout)findViewById(R.id.llTabHeader);
   	btnLoginTab = (Button) findViewById(R.id.btnTabLeft);
	btnRegisterTab = (Button) findViewById(R.id.btnTabRight);
	etUsername = (EditText) findViewById(R.id.etPassportUsername);
	etPassword = (EditText) findViewById(R.id.etPassportPassword);
	etPasswordConfirmed = (EditText) findViewById(R.id.etPassportPasswordConfirmed);
	etEmail = (EditText) findViewById(R.id.etPassportEmail);
	
	LinearLayout llFooterAction = (LinearLayout)findViewById(R.id.llFooterAction);
	btnFormSubmit = (Button) findViewById(R.id.btnPassportFormSubmit);
	btnFormReset = (Button) findViewById(R.id.btnPassportFormReset);
	
   	ThemeUtil.setSecondaryHeader(llHeaderBase);
   	ThemeUtil.setRootBackground(llRoot);
   	ThemeUtil.setHeaderToggleTab(llTabHeader);
   	int content = theme.getColor("content");
   	etUsername.setBackgroundDrawable(theme.getDrawable("selector_input_frame"));
   	etUsername.setTextColor(content);
   	etPassword.setBackgroundDrawable(theme.getDrawable("selector_input_frame"));
   	etPassword.setTextColor(content);
   	etPasswordConfirmed.setBackgroundDrawable(theme.getDrawable("selector_input_frame"));
   	etPasswordConfirmed.setTextColor(content);
   	etEmail.setBackgroundDrawable(theme.getDrawable("selector_input_frame"));
   	etEmail.setTextColor(content);
	
   	llFooterAction.setBackgroundDrawable(theme.getDrawable("bg_footer_action"));
   	int padding8 = theme.dip2px(8);
   	llFooterAction.setPadding(padding8, padding8, padding8, padding8);
   	llFooterAction.setGravity(Gravity.CENTER);
   	ThemeUtil.setBtnActionPositive(btnFormSubmit);
   	ThemeUtil.setBtnActionNegative(btnFormReset);
   	
   	btnLoginTab.setText(R.string.label_passport_login);
   	btnRegisterTab.setText(R.string.label_passport_register);
}
 
Example 8
Source File: MainActivity.java    From android-CommitContentSampleApp with Apache License 2.0 5 votes vote down vote up
/**
 * Creates a new instance of {@link EditText} that is configured to specify the given content
 * MIME types to EditorInfo#contentMimeTypes so that developers can locally test how the current
 * input method behaves for such content MIME types.
 *
 * @param contentMimeTypes A {@link String} array that indicates the supported content MIME
 *                         types
 * @return a new instance of {@link EditText}, which specifies EditorInfo#contentMimeTypes with
 * the given content MIME types
 */
private EditText createEditTextWithContentMimeTypes(String[] contentMimeTypes) {
    final CharSequence hintText;
    final String[] mimeTypes;  // our own copy of contentMimeTypes.
    if (contentMimeTypes == null || contentMimeTypes.length == 0) {
        hintText = "MIME: []";
        mimeTypes = new String[0];
    } else {
        hintText = "MIME: " + Arrays.toString(contentMimeTypes);
        mimeTypes = Arrays.copyOf(contentMimeTypes, contentMimeTypes.length);
    }
    EditText exitText = new EditText(this) {
        @Override
        public InputConnection onCreateInputConnection(EditorInfo editorInfo) {
            final InputConnection ic = super.onCreateInputConnection(editorInfo);
            EditorInfoCompat.setContentMimeTypes(editorInfo, mimeTypes);
            final InputConnectionCompat.OnCommitContentListener callback =
                    new InputConnectionCompat.OnCommitContentListener() {
                        @Override
                        public boolean onCommitContent(InputContentInfoCompat inputContentInfo,
                                int flags, Bundle opts) {
                            return MainActivity.this.onCommitContent(
                                    inputContentInfo, flags, opts, mimeTypes);
                        }
                    };
            return InputConnectionCompat.createWrapper(ic, editorInfo, callback);
        }
    };
    exitText.setHint(hintText);
    exitText.setTextColor(Color.WHITE);
    exitText.setHintTextColor(Color.WHITE);
    return exitText;
}
 
Example 9
Source File: PinViewBaseHelper.java    From PinView with Apache License 2.0 5 votes vote down vote up
/**
 * Set a PinBox with all attributes
 *
 * @param editText to set attributes
 */
private void setStylePinBox(EditText editText) {
    editText.setFilters(new InputFilter[]{new InputFilter.LengthFilter(mNumberCharacters)});

    if (mMaskPassword) {
        editText.setTransformationMethod(PasswordTransformationMethod.getInstance());
    }
    else{
        editText.setTransformationMethod(HideReturnsTransformationMethod.getInstance());
    }

    if (mNativePinBox) {
        if (android.os.Build.VERSION.SDK_INT < android.os.Build.VERSION_CODES.JELLY_BEAN) {
            //noinspection deprecation
            editText.setBackgroundDrawable(new EditText(getContext()).getBackground());
        } else {
            editText.setBackground(new EditText(getContext()).getBackground());
        }
    } else {
        editText.setBackgroundResource(mCustomDrawablePinBox);
    }

    if (mColorTextPinBoxes != PinViewSettings.DEFAULT_TEXT_COLOR_PIN_BOX) {
        editText.setTextColor(mColorTextPinBoxes);
    }
    editText.setTextSize(PinViewUtils.convertPixelToDp(getContext(), mTextSizePinBoxes));
}
 
Example 10
Source File: WithItemTextView.java    From BigApp_Discuz_Android with Apache License 2.0 4 votes vote down vote up
private void init(Context context, AttributeSet attrs) {
    TypedArray a = context.obtainStyledAttributes(attrs,
            R.styleable.WithItemTextView);
    String name = a
            .getString(R.styleable.WithItemTextView_WithItemTextView_name);
    String content = a
            .getString(R.styleable.WithItemTextView_WithItemTextView_content);

    int color_name = a.getColor(
            R.styleable.WithItemTextView_WithItemTextView_name_color,
            getResources().getColor(R.color.black));
    int color_content = a.getColor(
            R.styleable.WithItemTextView_WithItemTextView_content_color,
            getResources().getColor(R.color.gray));
    int color_content_hint = a.getColor(
            R.styleable.WithItemTextView_WithItemTextView_edit_hint_color,
            getResources().getColor(R.color.gray));

    Drawable arrow = a.getDrawable(R.styleable.WithItemTextView_WithItemTextView_content_arrow);

    boolean editable = a.getBoolean(R.styleable.WithItemTextView_WithItemTextView_editable, false);

    View view = LayoutInflater.from(context).inflate(
            R.layout.z_layout_item, null);
    ImageView iv_arrow = (ImageView) view.findViewById(R.id.iv_arrow);
    iv_arrow.setImageDrawable(arrow);
    mTv_name = (TextView) view.findViewById(R.id.tv_name);
    mEt_content = (EditText) view.findViewById(R.id.et_content);
    mTv_content = (TextView) view.findViewById(R.id.tv_content);
    mTv_name.setTextColor(color_name);
    mTv_content.setTextColor(color_content);
    mTv_name.setText(name);
    mTv_content.setText(content);
    if (editable) {
        mEt_content.setHint(content);
        mEt_content.setTextColor(color_content);
        mEt_content.setHintTextColor(color_content_hint);
        mTv_content.setVisibility(View.GONE);
        mEt_content.setVisibility(View.VISIBLE);
    }
    LinearLayout.LayoutParams lp = new LinearLayout.LayoutParams(
            LayoutParams.MATCH_PARENT, LinearLayout.LayoutParams.MATCH_PARENT);
    view.setLayoutParams(lp);
    a.recycle();
    addView(view);
}
 
Example 11
Source File: DarkSearchView.java    From mollyim-android with GNU General Public License v3.0 4 votes vote down vote up
public DarkSearchView(@NonNull Context context, @Nullable AttributeSet attrs, @AttrRes int defStyleAttr) {
  super(context, attrs, defStyleAttr);

  EditText searchText = findViewById(androidx.appcompat.R.id.search_src_text);
  searchText.setTextColor(ThemeUtil.getThemedColor(context, R.attr.conversation_subtitle_color));
}
 
Example 12
Source File: EditPagePort.java    From POCenter with MIT License 4 votes vote down vote up
private void initBody(RelativeLayout rlBody, float ratio) {
	svContent = new ScrollView(activity);
	rlBody.addView(svContent, new RelativeLayout.LayoutParams(LayoutParams.MATCH_PARENT, LayoutParams.WRAP_CONTENT));

	LinearLayout llContent = new LinearLayout(activity);
	llContent.setOrientation(LinearLayout.VERTICAL);
	svContent.addView(llContent, new ScrollView.LayoutParams(LayoutParams.MATCH_PARENT, LayoutParams.WRAP_CONTENT));

	etContent = new EditText(activity);
	int padding = (int) (DESIGN_LEFT_PADDING * ratio);
	etContent.setPadding(padding, padding, padding, padding);
	etContent.setBackgroundDrawable(null);
	etContent.setTextColor(0xff3b3b3b);
	etContent.setTextSize(TypedValue.COMPLEX_UNIT_SP, 21);
	etContent.setText(sp.getText());
	LinearLayout.LayoutParams lp = new LinearLayout.LayoutParams(LayoutParams.MATCH_PARENT, LayoutParams.WRAP_CONTENT);
	llContent.addView(etContent, lp);
	etContent.addTextChangedListener(this);

	rlThumb = new RelativeLayout(activity);
	rlThumb.setBackgroundColor(0xff313131);
	int	thumbWidth = (int) (DESIGN_THUMB_HEIGHT * ratio);
	int	xWidth = (int) (DESIGN_REMOVE_THUMB_HEIGHT * ratio);
	lp = new LinearLayout.LayoutParams(thumbWidth, thumbWidth);
	lp.leftMargin = lp.rightMargin = lp.bottomMargin = lp.topMargin = padding;
	llContent.addView(rlThumb, lp);

	aivThumb = new AsyncImageView(activity) {
		public void onImageGot(String url, Bitmap bm) {
			thumb = bm;
			super.onImageGot(url, bm);
		}
	};
	aivThumb.setScaleToCropCenter(true);
	RelativeLayout.LayoutParams rllp = new RelativeLayout.LayoutParams(thumbWidth, thumbWidth);
	rlThumb.addView(aivThumb, rllp);
	aivThumb.setOnClickListener(this);
	initThumb(aivThumb);

	xvRemove = new XView(activity);
	xvRemove.setRatio(ratio);
	rllp = new RelativeLayout.LayoutParams(xWidth, xWidth);
	rllp.addRule(RelativeLayout.ALIGN_PARENT_TOP);
	rllp.addRule(RelativeLayout.ALIGN_PARENT_RIGHT);
	rlThumb.addView(xvRemove, rllp);
	xvRemove.setOnClickListener(this);
}
 
Example 13
Source File: MainActivity.java    From mil-sym-android with Apache License 2.0 4 votes vote down vote up
/**
 * Called when the activity is first created.
 */
@Override
public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.main);
    FragmentManager f = getFragmentManager();
    mapFragment = ((MapFragment) getFragmentManager().findFragmentById(R.id.map));       
    map = mapFragment.getMap();
    map.getUiSettings().setZoomControlsEnabled(true);
    map.setMapType(GoogleMap.MAP_TYPE_SATELLITE);
    map.setBuildingsEnabled(true);        
    if (myView == null) {
        myView = new MyView(this);
        myView.map = map;
    }
    utility.map = map;
    loadRenderer();

    editText = (EditText) findViewById(R.id.edit_message);
    editText.setTextColor(Color.RED);
    editText.setText("flot");
    map.setOnMapClickListener(new GoogleMap.OnMapClickListener() {
        @Override
        public void onMapClick(LatLng point) {
            //this should instead be set by an event handler for editText
            MyView.linetype = editText.getText().toString().toUpperCase(Locale.US);
            myView.onTouchEvent(point);
            return;
        }
    });
    map.setOnCameraChangeListener(new GoogleMap.OnCameraChangeListener() {

        private float currentZoom = -1;

        @Override
        public void onCameraChange(CameraPosition pos) {
            if (pos.zoom != currentZoom) {
                currentZoom = pos.zoom;
            }
            myView.setExtents();
            myView.DrawFromZoom(null);
        }
    }
    );
}
 
Example 14
Source File: EditPagePort.java    From Social with Apache License 2.0 4 votes vote down vote up
private void initBody(RelativeLayout rlBody, float ratio) {
	svContent = new ScrollView(activity);
	rlBody.addView(svContent, new RelativeLayout.LayoutParams(LayoutParams.MATCH_PARENT, LayoutParams.WRAP_CONTENT));

	LinearLayout llContent = new LinearLayout(activity);
	llContent.setOrientation(LinearLayout.VERTICAL);
	svContent.addView(llContent, new ScrollView.LayoutParams(LayoutParams.MATCH_PARENT, LayoutParams.WRAP_CONTENT));

	etContent = new EditText(activity);
	int padding = (int) (DESIGN_LEFT_PADDING * ratio);
	etContent.setPadding(padding, padding, padding, padding);
	etContent.setBackgroundDrawable(null);
	etContent.setTextColor(0xff3b3b3b);
	etContent.setTextSize(TypedValue.COMPLEX_UNIT_SP, 21);
	etContent.setText(sp.getText());
	LinearLayout.LayoutParams lp = new LinearLayout.LayoutParams(LayoutParams.MATCH_PARENT, LayoutParams.WRAP_CONTENT);
	llContent.addView(etContent, lp);
	etContent.addTextChangedListener(this);

	rlThumb = new RelativeLayout(activity);
	rlThumb.setBackgroundColor(0xff313131);
	int	thumbWidth = (int) (DESIGN_THUMB_HEIGHT * ratio);
	int	xWidth = (int) (DESIGN_REMOVE_THUMB_HEIGHT * ratio);
	lp = new LinearLayout.LayoutParams(thumbWidth, thumbWidth);
	lp.leftMargin = lp.rightMargin = lp.bottomMargin = lp.topMargin = padding;
	llContent.addView(rlThumb, lp);

	aivThumb = new AsyncImageView(activity) {
		public void onImageGot(String url, Bitmap bm) {
			thumb = bm;
			super.onImageGot(url, bm);
		}
	};
	aivThumb.setScaleToCropCenter(true);
	RelativeLayout.LayoutParams rllp = new RelativeLayout.LayoutParams(thumbWidth, thumbWidth);
	rlThumb.addView(aivThumb, rllp);
	aivThumb.setOnClickListener(this);
	initThumb(aivThumb);

	xvRemove = new XView(activity);
	xvRemove.setRatio(ratio);
	rllp = new RelativeLayout.LayoutParams(xWidth, xWidth);
	rllp.addRule(RelativeLayout.ALIGN_PARENT_TOP);
	rllp.addRule(RelativeLayout.ALIGN_PARENT_RIGHT);
	rlThumb.addView(xvRemove, rllp);
	xvRemove.setOnClickListener(this);
}
 
Example 15
Source File: TransitionEditView.java    From PLDroidShortVideo with Apache License 2.0 4 votes vote down vote up
private void cloneEditText(EditText dstText, EditText srcText) {
    dstText.setText(srcText.getText());
    dstText.setTextColor(srcText.getTextColors());
    dstText.setTypeface(srcText.getTypeface());
    dstText.setTextSize(TypedValue.COMPLEX_UNIT_PX, srcText.getTextSize());
}
 
Example 16
Source File: AddConfigAppActivity.java    From YiBo with Apache License 2.0 4 votes vote down vote up
private void initCompoments() {
	TextView tvTitle = (TextView) findViewById(R.id.tvTitle);
	tvTitle.setText(R.string.title_add_config_app);
	
	LinearLayout llRoot = (LinearLayout)findViewById(R.id.llRoot);
   	LinearLayout llHeaderBase = (LinearLayout)findViewById(R.id.llHeaderBase);

   	etAppName = (EditText) findViewById(R.id.etAppName);
	etAppKey = (EditText) findViewById(R.id.etAppKey);
	etAppSecret = (EditText) findViewById(R.id.etAppSecret);
	etCallbackUrl = (EditText) findViewById(R.id.etCallbackUrl);
	etCallbackUrl.setVisibility(View.GONE);
	Authorization auth = new Authorization(sp);
	if (auth.getAuthVersion() == Authorization.AUTH_VERSION_OAUTH_2) {
		etCallbackUrl.setVisibility(View.VISIBLE);
	}
	
	LinearLayout llFooterAction = (LinearLayout)findViewById(R.id.llFooterAction);
	btnFooterActionSubmit = (Button) findViewById(R.id.btnFooterActionSubmit);
	btnFooterActionReset = (Button) findViewById(R.id.btnFooterActionReset);
	
   	ThemeUtil.setSecondaryHeader(llHeaderBase);
   	ThemeUtil.setRootBackground(llRoot);
   	int content = theme.getColor("content");
   	etAppName.setBackgroundDrawable(theme.getDrawable("selector_input_frame"));
   	etAppName.setTextColor(content);
   	etAppKey.setBackgroundDrawable(theme.getDrawable("selector_input_frame"));
   	etAppKey.setTextColor(content);
   	etAppSecret.setBackgroundDrawable(theme.getDrawable("selector_input_frame"));
   	etAppSecret.setTextColor(content);
   	etCallbackUrl.setBackgroundDrawable(theme.getDrawable("selector_input_frame"));
   	etCallbackUrl.setTextColor(content);
	
   	llFooterAction.setBackgroundDrawable(theme.getDrawable("bg_footer_action"));
   	int padding8 = theme.dip2px(8);
   	llFooterAction.setPadding(padding8, padding8, padding8, padding8);
   	llFooterAction.setGravity(Gravity.CENTER);
   	ThemeUtil.setBtnActionPositive(btnFooterActionSubmit);
   	ThemeUtil.setBtnActionNegative(btnFooterActionReset);
   	
}
 
Example 17
Source File: ProfileEditActivity.java    From YiBo with Apache License 2.0 4 votes vote down vote up
private void initComponents() {
	LinearLayout llHeaderBase = (LinearLayout)findViewById(R.id.llHeaderBase);
   	ThemeUtil.setSecondaryHeader(llHeaderBase);
   	
   	//个人资料头部
   	LinearLayout llProfileHeader = (LinearLayout)findViewById(R.id.llProfileHeader);
	tvScreenName = (TextView)findViewById(R.id.tvScreenName);
	ivVerify = (ImageView)findViewById(R.id.ivVerify);
	tvImpress = (TextView)findViewById(R.id.tvImpress);
	ThemeUtil.setHeaderProfile(llProfileHeader);
	Theme theme = ThemeUtil.createTheme(this);
	tvScreenName.setTextColor(theme.getColor("highlight"));
	ivVerify.setImageDrawable(GlobalResource.getIconVerification(this));
	tvImpress.setTextColor(theme.getColor("content"));
	
	//内容编辑
	ScrollView llContentPanel = (ScrollView)findViewById(R.id.llContentPanel);
	LinearLayout llChangeProfilePhoto = (LinearLayout)findViewById(R.id.llChangeProfilePhoto);
	ImageView ivProfileEdit = (ImageView)findViewById(R.id.ivProfileEdit);
	TextView tvProfileEdit = (TextView)findViewById(R.id.tvProfileEdit);
	etScreenName = (EditText) this.findViewById(R.id.etProfileScreenName);
	etDescription = (EditText) this.findViewById(R.id.etProfileDescription);
	llContentPanel.setBackgroundColor(theme.getColor("background_content"));
	llChangeProfilePhoto.setBackgroundDrawable(theme.getDrawable("selector_btn_action_negative"));
	ivProfileEdit.setImageDrawable(theme.getDrawable("icon_profile_edit"));
	tvProfileEdit.setTextColor(theme.getColorStateList("selector_btn_action_negative"));
	etScreenName.setBackgroundDrawable(theme.getDrawable("selector_input_frame"));
	int content = theme.getColor("content");
	etScreenName.setTextColor(content);
	etDescription.setBackgroundDrawable(theme.getDrawable("selector_input_frame"));
	etDescription.setTextColor(content);
	
	//工具条
       LinearLayout llToolbar = (LinearLayout)findViewById(R.id.llToolbar);
       Button btnProfileUpdate = (Button)findViewById(R.id.btnProfileUpdate);
       Button btnProfileReset = (Button)findViewById(R.id.btnProfileReset);
       llToolbar.setBackgroundDrawable(theme.getDrawable("bg_toolbar"));
       llToolbar.setGravity(Gravity.CENTER);
       int padding4 = theme.dip2px(4);
       llToolbar.setPadding(padding4, padding4, padding4, padding4);
       ThemeUtil.setBtnActionPositive(btnProfileUpdate);
       ThemeUtil.setBtnActionNegative(btnProfileReset);        
	
	profileTextWatcher = new ProfileTextWatcher(this);
	Button btnFollow = (Button) this.findViewById(R.id.btnFollow);
	btnFollow.setVisibility(View.INVISIBLE);
}
 
Example 18
Source File: ContactSelectActivity.java    From weMessage with GNU Affero General Public License v3.0 4 votes vote down vote up
private void resetEditText( EditText editText){
    editText.setTextColor(oldEditTextColor);
}
 
Example 19
Source File: EditFragment.java    From pandora with Apache License 2.0 4 votes vote down vote up
@Override
protected View getLayoutView() {
    View wrapper;
    editText = new EditText(getContext());
    int padding = ViewKnife.dip2px(16);
    editText.setPadding(padding, padding, padding, padding);
    editText.setBackgroundColor(Color.WHITE);
    editText.setGravity(Gravity.START | Gravity.TOP);
    editText.setTextColor(ViewKnife.getColor(R.color.pd_label_dark));
    editText.setLineSpacing(0, 1.2f);

    String[] options = getArguments().getStringArray(PARAM3);
    if (options != null && options.length > 0) {
        LinearLayout layout = new LinearLayout(getContext());
        layout.setOrientation(LinearLayout.VERTICAL);
        wrapper = layout;
        RecyclerView recyclerView = new RecyclerView(getContext());
        recyclerView.setBackgroundColor(Color.WHITE);
        LinearLayoutManager manager = new LinearLayoutManager(getContext());
        manager.setOrientation(LinearLayoutManager.HORIZONTAL);
        recyclerView.setLayoutManager(manager);
        UniversalAdapter adapter = new UniversalAdapter();
        recyclerView.setAdapter(adapter);
        adapter.setListener(new UniversalAdapter.OnItemClickListener() {
            @Override
            public void onItemClick(int position, BaseItem item) {
                notifyResult(((OptionItem)item).data);
            }
        });
        List<BaseItem> items = new ArrayList<>(options.length);
        for (String option : options) {
            items.add(new OptionItem(option));
        }
        adapter.setItems(items);

        LinearLayout.LayoutParams recyclerParam = new LinearLayout.LayoutParams(
                ViewGroup.LayoutParams.MATCH_PARENT, ViewKnife.dip2px(50)
        );
        layout.addView(recyclerView, recyclerParam);
        LinearLayout.LayoutParams editParam = new LinearLayout.LayoutParams(
                ViewGroup.LayoutParams.MATCH_PARENT,
                ViewGroup.LayoutParams.MATCH_PARENT
        );
        layout.addView(editText, editParam);
    } else {
        wrapper = editText;
    }
    return wrapper;
}
 
Example 20
Source File: EditPagePort.java    From GithubApp with Apache License 2.0 4 votes vote down vote up
private void initBody(RelativeLayout rlBody, float ratio) {
	svContent = new ScrollView(activity);
	rlBody.addView(svContent, new RelativeLayout.LayoutParams(LayoutParams.MATCH_PARENT, LayoutParams.WRAP_CONTENT));

	LinearLayout llContent = new LinearLayout(activity);
	llContent.setOrientation(LinearLayout.VERTICAL);
	svContent.addView(llContent, new ScrollView.LayoutParams(LayoutParams.MATCH_PARENT, LayoutParams.WRAP_CONTENT));

	etContent = new EditText(activity);
	int padding = (int) (DESIGN_LEFT_PADDING * ratio);
	etContent.setPadding(padding, padding, padding, padding);
	etContent.setBackgroundDrawable(null);
	etContent.setTextColor(0xff3b3b3b);
	etContent.setTextSize(TypedValue.COMPLEX_UNIT_SP, 21);
	etContent.setText(sp.getText());
	LinearLayout.LayoutParams lp = new LinearLayout.LayoutParams(LayoutParams.MATCH_PARENT, LayoutParams.WRAP_CONTENT);
	llContent.addView(etContent, lp);
	etContent.addTextChangedListener(this);

	rlThumb = new RelativeLayout(activity);
	rlThumb.setBackgroundColor(0xff313131);
	int	thumbWidth = (int) (DESIGN_THUMB_HEIGHT * ratio);
	int	xWidth = (int) (DESIGN_REMOVE_THUMB_HEIGHT * ratio);
	lp = new LinearLayout.LayoutParams(thumbWidth, thumbWidth);
	lp.leftMargin = lp.rightMargin = lp.bottomMargin = lp.topMargin = padding;
	llContent.addView(rlThumb, lp);

	aivThumb = new AsyncImageView(activity) {
		public void onImageGot(String url, Bitmap bm) {
			thumb = bm;
			super.onImageGot(url, bm);
		}
	};
	aivThumb.setScaleToCropCenter(true);
	RelativeLayout.LayoutParams rllp = new RelativeLayout.LayoutParams(thumbWidth, thumbWidth);
	rlThumb.addView(aivThumb, rllp);
	aivThumb.setOnClickListener(this);
	initThumb(aivThumb);

	xvRemove = new XView(activity);
	xvRemove.setRatio(ratio);
	rllp = new RelativeLayout.LayoutParams(xWidth, xWidth);
	rllp.addRule(RelativeLayout.ALIGN_PARENT_TOP);
	rllp.addRule(RelativeLayout.ALIGN_PARENT_RIGHT);
	rlThumb.addView(xvRemove, rllp);
	xvRemove.setOnClickListener(this);
}