布局没啥特别的
<EditText android:id="@+id/embedded_text_editor"
                    android:layout_width="fill_parent"
                    android:layout_height="fill_parent"
                    android:layout_weight="1.0" 
                    android:autoText="true"
                    android:capitalize="sentences"
                    android:hint="@string/type_to_compose_text_enter_to_send"
                    android:textCursorDrawable="@null"
     android:textColor="@android:color/black"
                    android:maxLines="4"
                    android:nextFocusRight="@+id/send_button"
                    android:gravity="top" />

解决方案 »

  1.   

            int newHeight = 200;
            //注意这里,到底是用ViewGroup还是用LinearLayout或者是FrameLayout,主要是看你这个EditTex
            //控件所在的父控件是啥布局,如果是LinearLayout,那么这里就要改成LinearLayout.LayoutParams
            ViewGroup.LayoutParams lp = editText.getLayoutParams();
            lp.height = newHeight;
            editText.setLayoutParams(lp);
      

  2.   

    嗯,谢谢,这个可以设置。。我想问下,有没有办法让那个edittext显示一行,因为要考虑手机分辨率的问题,可能设置固定的高度不好。。如果可以设置一行显示的,会感觉好一点
      

  3.   


    嗯,谢谢,这个可以设置。。我想问下,有没有办法让那个edittext显示一行,因为要考虑手机分辨率的问题,可能设置固定的高度不好。。如果可以设置一行显示的,会感觉好一点
      

  4.   


    嗯,谢谢,这个可以设置。。我想问下,有没有办法让那个edittext显示一行,因为要考虑手机分辨率的问题,可能设置固定的高度不好。。如果可以设置一行显示的,会感觉好一点你在调用setMaxLines之前,先调用setSingleLine(false);
    edittext.setSingleLine(false);
    edittext.setMaxLines(2);
      

  5.   


    嗯,谢谢,这个可以设置。。我想问下,有没有办法让那个edittext显示一行,因为要考虑手机分辨率的问题,可能设置固定的高度不好。。如果可以设置一行显示的,会感觉好一点你在调用setMaxLines之前,先调用setSingleLine(false);
    edittext.setSingleLine(false);
    edittext.setMaxLines(2);没反应的啊,按你写的。不知道为啥,网上一般都是这样写的。。我把整个父布局贴出来
      <LinearLayout
                    android:id="@+id/bottom_panel"
                    android:layout_width="match_parent"
                    android:layout_height="wrap_content"
                    android:orientation="horizontal"
                    android:paddingBottom="2dip"
                    android:paddingLeft="5dip"
                    android:paddingRight="5dip"
                    android:paddingTop="5dip" >
                    <RelativeLayout
                        android:id="@+id/editor_with_counter"
                        android:layout_width="wrap_content"
                        android:layout_height="match_parent"
                        android:layout_weight="1.0"
                        android:orientation="horizontal" > 
        
                    <EditText android:id="@+id/embedded_text_editor"
                        android:layout_width="fill_parent"
                        android:layout_height="fill_parent"
                        android:layout_weight="1.0" 
                        android:autoText="true"
                        android:capitalize="sentences"
                        android:hint="@string/type_to_compose_text_enter_to_send"
                        android:textCursorDrawable="@null"
         android:textColor="@android:color/black"
                        android:maxLines="4"
                        android:nextFocusRight="@+id/send_button"
                        android:gravity="top" />
      

  6.   


    嗯,谢谢,这个可以设置。。我想问下,有没有办法让那个edittext显示一行,因为要考虑手机分辨率的问题,可能设置固定的高度不好。。如果可以设置一行显示的,会感觉好一点你在调用setMaxLines之前,先调用setSingleLine(false);
    edittext.setSingleLine(false);
    edittext.setMaxLines(2);没反应的啊,按你写的。不知道为啥,网上一般都是这样写的。。我把整个父布局贴出来
      <LinearLayout
                    android:id="@+id/bottom_panel"
                    android:layout_width="match_parent"
                    android:layout_height="wrap_content"
                    android:orientation="horizontal"
                    android:paddingBottom="2dip"
                    android:paddingLeft="5dip"
                    android:paddingRight="5dip"
                    android:paddingTop="5dip" >
                    <RelativeLayout
                        android:id="@+id/editor_with_counter"
                        android:layout_width="wrap_content"
                        android:layout_height="match_parent"
                        android:layout_weight="1.0"
                        android:orientation="horizontal" > 
        
                    <EditText android:id="@+id/embedded_text_editor"
                        android:layout_width="fill_parent"
                        android:layout_height="fill_parent"
                        android:layout_weight="1.0" 
                        android:autoText="true"
                        android:capitalize="sentences"
                        android:hint="@string/type_to_compose_text_enter_to_send"
                        android:textCursorDrawable="@null"
         android:textColor="@android:color/black"
                        android:maxLines="4"
                        android:nextFocusRight="@+id/send_button"
                        android:gravity="top" />
    哦,对了
    setSingleLine(false);要放在setText前面。
    也就是最后再调用setText试试