要求:
1、整个界面刚好填满屏幕,不需要滚动
2、输入反馈内容的EditText控件高度能够自适应
3、提交按钮位于屏幕最下方
核心布局文件如下:
- <?xml version="1.0" encoding="utf-8"?>
- <LinearLayout
- xmlns:android="http://schemas.android.com/apk/res/android"
- android:orientation="vertical"
- android:layout_width="fill_parent"
- android:layout_height="fill_parent">
- <TextView
- android:text="用户反馈"
- android:layout_width="fill_parent"
- android:layout_height="40dip"
- android:background="#363433"
- android:textColor="#FFFFFF"
- android:gravity="center"
- android:textSize="20sp"/>
- <LinearLayout android:orientation="vertical"
- android:layout_width="fill_parent"
- android:layout_height="fill_parent"
- android:paddingLeft="10dp"
- android:paddingRight="10dp">
- <TextView android:id="@+id/feedback_title"
- android:layout_width="fill_parent"
- android:layout_height="wrap_content"
- android:textSize="19dp"
- android:textColor="#706F6D"
- android:layout_marginTop="10dp"
- android:layout_marginBottom="10dp"
- android:text="欢迎您提出宝贵的意见和建议,您的建议对我们改善服务非常有帮助。">
- </TextView>
- <LinearLayout android:orientation="horizontal"
- android:layout_width="fill_parent"
- android:layout_height="wrap_content"
- android:layout_marginTop="10dp" >
- <Spinner android:id="@+id/feedback_type_spinner"
- android:layout_width="wrap_content"
- android:layout_height="50dp"
- android:layout_weight="1"
- android:focusable="true"
- android:entries="@array/feedback_type"/>
- </LinearLayout>
- <RelativeLayout android:layout_width="fill_parent"
- android:layout_height="fill_parent">
- <EditText android:id="@+id/feedback_content"
- android:layout_width="fill_parent"
- android:layout_height="fill_parent"
- android:maxEms="10"
- android:minEms="10"
- android:hint="请输入您的反馈意见(字数500以内)"
- android:gravity="top"
- android:layout_marginBottom="50dip"/>
- <Button android:id="@+id/feedback_submit"
- android:layout_width="fill_parent"
- android:layout_height="50dp"
- android:text="提交反馈"
- android:textSize="19dp"
- android:layout_gravity="center_horizontal"
- android:layout_alignParentBottom="true"/>
- </RelativeLayout>
- </LinearLayout>
- </LinearLayout>
运行截图如下:
备注:
在打开的activity界面中如果包含有EditText控件,那么android默认会打开键盘输入法,但是很多时候不需要,可以通过下面的代码隐藏掉键盘:
- getWindow().setSoftInputMode(WindowManager.LayoutParams.SOFT_INPUT_STATE_ALWAYS_HIDDEN);