在Android中,如下面局:
这个时候,你输入了多行文本的时候,会发现有一部份只显示一半,或者边框下边变窄。原因是因为左边的TextView引起的,具体原因我不知道 不过有一个解决办法,就是在EditText外层加上一个LinearLayout就好了如:
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginBottom="5dp"
android:layout_marginLeft="@dimen/default_margin"
android:layout_marginRight="@dimen/default_margin"
android:layout_marginTop="5dp"
android:focusable="true"
android:focusableInTouchMode="true"
android:orientation="horizontal">
<TextView
android:layout_width="wrap_content"
android:layout_height="45dp"
android:gravity="center_vertical|left"
android:text="@string/remark"
android:textColor="@android:color/black"
android:textSize="@dimen/default_text_size"/>
<EditText
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="@drawable/bg_corner_5_rect_shape_gray"
android:freezesText="true"
android:gravity="center_vertical"
android:padding="5dp"
android:inputType="textMultiLine"
android:minHeight="45dp"
android:paddingLeft="@dimen/default_padding"
android:paddingRight="@dimen/default_padding"
/>
</LinearLayout>
这个时候,你输入了多行文本的时候,会发现有一部份只显示一半,或者边框下边变窄。原因是因为左边的TextView引起的,具体原因我不知道 不过有一个解决办法,就是在EditText外层加上一个LinearLayout就好了如:
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginBottom="5dp"
android:layout_marginLeft="@dimen/default_margin"
android:layout_marginRight="@dimen/default_margin"
android:layout_marginTop="5dp"
android:focusable="true"
android:focusableInTouchMode="true"
android:orientation="horizontal">
<TextView
android:layout_width="wrap_content"
android:layout_height="45dp"
android:gravity="center_vertical|left"
android:text="@string/remark"
android:textColor="@android:color/black"
android:textSize="@dimen/default_text_size"/>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"〉
<EditText
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="@drawable/bg_corner_5_rect_shape_gray"
android:freezesText="true"
android:gravity="center_vertical"
android:padding="5dp"
android:inputType="textMultiLine"
android:minHeight="45dp"
android:paddingLeft="@dimen/default_padding"
android:paddingRight="@dimen/default_padding"
/>
</LinearLayout>
</LinearLayout>