1、子控件不受父控件的大小的控制
android:clipChildren="false"

2、TextView/ EditText 单行显示

android:singleLine="true"

3、EditText字数限制

android:maxLength="100"

其他小知识点_第1张图片

  <FrameLayout       android:id="@+id/content_appraise"       android:layout_below="@id/t54yh67u"       android:background="#ffffff"       android:orientation="vertical"       android:layout_marginTop="9dip"       android:layout_marginLeft="10dp"       android:layout_marginRight="10dp"       android:paddingBottom="8dp"       android:paddingTop="8dp"       android:paddingLeft="8dp"       android:paddingRight="8dp"           android:layout_width="match_parent"       android:layout_height="170dp" >             <EditText            android:id="@+id/et_appraise_content"           android:layout_width="match_parent"           android:layout_height="match_parent"           android:paddingLeft="8dp"           android:paddingTop="8dp"           android:gravity="left"           android:background="@null"           android:hint="请填写对医生回答的评论(选填)"           android:maxLength="100"/>             <TextView           android:id="@+id/tv_num_limit_content"           android:layout_width="match_parent"           android:layout_height="match_parent"           android:gravity="right|bottom"           android:text="0/100" >                  </TextView>              </FrameLayout>

然后再Activity中监听EditText的变化。

tv_num_limit_content = (TextView) this.findViewById(R.id.tv_num_limit_content) ;        et_appraise_content = (EditText) this.findViewById(R.id.et_appraise_content);        et_appraise_content.addTextChangedListener(new TextWatcher() {            @Override            public void afterTextChanged(Editable arg0) {                            }            @Override            public void beforeTextChanged(CharSequence arg0, int arg1,                    int arg2, int arg3) {                            }            @Override            public void onTextChanged(CharSequence arg0, int arg1, int arg2,                    int arg3) {                tv_num_limit_content.setText(""+arg0.length()+"/100");            }                    });

更多相关文章

  1. 怎么给Android(安卓)控件添加边框(样式)?
  2. android 自定义控件(邮箱边写边出格式邮箱)
  3. 自定义控件--虚线
  4. android之4.0控件switch自定义开关滑块、滑块轨道和宽度
  5. Android中WebView控件的使用
  6. Android Studio 新建编辑条 点击按钮显示控件中的内容
  7. android 关于listview scrollview 底部 控件无法显示的两个解决
  8. android TextView控件属性列表
  9. android 常用控件一览(从底层分析,为自定义控件做下小铺垫)

随机推荐

  1. 一起学opengl android
  2. 为什么我们可以在非UI线程中更新UI
  3. Android实现使用微信登录第三方APP的方法
  4. 从纪念碑谷 Monument Valley 登陆 Androi
  5. Android中AsyncTask的基本用法
  6. Android(安卓)UI 设计——TextView 控件
  7. Android(安卓)问题杂笔
  8. android 系统权限大全
  9. Android-Lifecycle超能解析-生命周期的那
  10. ubuntu下android开发环境配置及常用设置