我想知道如何将编辑文本的高度调整为te字体大小。我的意思是无论我将fontSize更改为5sp还是保留默认值,editText总是一样高。当然我可以使用这样的东西:
<EditText
android:id="@+id/msgInput"
android:layout_width="wrap_content"
android:layout_height="20dp"
android:inputType="textMultiLine"
android:textSize="14sp"
android:hint="@string/hintMsgInput">
</EditText>
Run Code Online (Sandbox Code Playgroud)
但如果有多于一条线,我也想拉伸。我该怎么做?
[编辑]:
好的,我是这样解决的:
msgInput = (EditText) findViewById(R.id.msgInput);
msgInput.addTextChangedListener(new TextWatcher()
{
public void afterTextChanged(Editable s) {
if (msgInput.getLineCount() > 1)
{
msgInput.setLayoutParams(new TableRow.LayoutParams(TableRow.LayoutParams.FILL_PARENT, TableRow.LayoutParams.WRAP_CONTENT));
}
else
{
int height = (int) TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_DIP, 40, getResources().getDisplayMetrics());
msgInput.setLayoutParams(new TableRow.LayoutParams(TableRow.LayoutParams.FILL_PARENT, height));
}
}
public void beforeTextChanged(CharSequence s, int start, int count,
int after) {
}
public void onTextChanged(CharSequence s, int start, int before,
int count) {
}
});
Run Code Online (Sandbox Code Playgroud) 我建立小型短信应用程序,我有一个问题.股票短信应用程序,例如GO短信,我可以选择向一个以上的人发送一条消息,之后两个应用程序都显示我在对话列表中.
http://dl.dropbox.com/u/18780140/group_sms.jpeg
但是我如何在自己的应用程序中检测到这一点?我尝试使用:content:// mms-sms/conversation,但它只显示一个地址与一个地址的对话,并且没有任何特殊的符号外观:(我发送了"Hyg"消息给数字:1003和0001(不同的消息)比截图上的这个))
D/ConversationAdapter(13012): body Hyg
D/ConversationAdapter(13012): person null
D/ConversationAdapter(13012): sub null
D/ConversationAdapter(13012): subject null
D/ConversationAdapter(13012): retr_st null
D/ConversationAdapter(13012): type 5
D/ConversationAdapter(13012): date 1330538860294
D/ConversationAdapter(13012): ct_cls null
D/ConversationAdapter(13012): sub_cs null
D/ConversationAdapter(13012): _id 510
D/ConversationAdapter(13012): read 1
D/ConversationAdapter(13012): ct_l null
D/ConversationAdapter(13012): tr_id null
D/ConversationAdapter(13012): st null
D/ConversationAdapter(13012): msg_box null
D/ConversationAdapter(13012): thread_id 86
D/ConversationAdapter(13012): reply_path_present null
D/ConversationAdapter(13012): m_cls null
D/ConversationAdapter(13012): read_status null
D/ConversationAdapter(13012): ct_t null
D/ConversationAdapter(13012): status -1
D/ConversationAdapter(13012): retr_txt_cs null
D/ConversationAdapter(13012): d_rpt null
D/ConversationAdapter(13012): error_code 0
D/ConversationAdapter(13012): m_id null
D/ConversationAdapter(13012): …Run Code Online (Sandbox Code Playgroud)