tags:

views:

1332

answers:

1

Hi, I am using EditText for getting userInput but the problem i am facing is that i want to change the font color at runtime but in the same Edittext as i am able to change the font type but as i change the font color it changes for the whole editext but i need to change the color for specfic text only .

And one more issue issue is that when making an edittext with the height more than the "fillparent" property i am getting the cursor postion in middle but i want it to be at the top always i.e. at the start ..

Is there any other widget available which will provide me the solution for both the problems Thnx in advance Any help would be appreciated

+2  A: 

Alignment of text within an EditText widget can be controlled via gravity:

editText.setGravity(Gravity.TOP);

To attach markup objects to the EditText's content you can use the Editable interface:

EditText editText = (EditText) findViewById(R.id.editview);
SpannableStringBuilder builder = new SpannableStringBuilder();
builder.append("one red word");
builder.setSpan(new ForegroundColorSpan(Color.RED), 4, 7, Spanned.SPAN_COMPOSING);
editText.setText(builder, BufferType.EDITABLE);
Josef
Hey thnx it worked ...... :-)
Sam97305421562