【发布时间】:2012-12-02 12:04:43
【问题描述】:
我在对话框中显示一些文本时遇到问题。当用户忘记密码时,我使用“忘记密码”TextView 来显示一条消息,解释当他们输入电子邮件地址时会发生什么。布局如下:
<TextView
android:id="@+id/forgotpasswordtextview"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="@string/forgotpassword"
android:textAppearance="?android:attr/textAppearanceMedium"
android:textColor="@color/md_text_yellow"
android:gravity="right" />
它位于<LinearLayout></LinearLayout> 内,具有以下属性:
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:background="@drawable/base_panel"
android:orientation="vertical"
android:padding="6dip" >
它从单行视图开始,然后扩展到四行视图。
在对话框构造函数中,我有一个布局说明:
mParent = LayoutInflater.from(context).inflate(R.layout.login, null);
setContentView(mParent, new ViewGroup.LayoutParams(LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT));
我将其更改为对话框高度为 600(它有效——一个垂直拉伸的对话框),TextView 仍然只显示四行,因此它不会被其父级压碎。
这可能是什么原因造成的?
编辑:
将TextView 更改为android:textAppearance="?android:attr/textAppearanceSmall" 在同一点切断字符串,显示三行。我现在想知道这是否是字符串问题而不是TextView 问题。
原来的字符串是:
Please enter your registered email and we will send you details of how to reset your password. If you do not know your email then please contact us.
它在以下位置切断:
Please enter your registered email and we will send you details of how to reset your password. If you do not
带有小文本(三行)和
Please enter your registered email and we will send you details of how to reset your password. If you do not know
中等文本(四行)。
我输入的新测试字符串是:
0________ 1________ 2________ 3________ 4________ 5________ 6________ 7________ 8________ 9________ 10_______ 11_______ 12_______ 13_______ 14_______ 15_______ 16_______ 17_______
它在以下位置切断:
0________ 1________ 2________ 3________ 4________ 5________ 6________ 7________ 8________ 9________ 10_______ 11_______ 12_______ 13_______ 14_______
带有小文本(五行)和
0________ 1________ 2________ 3________ 4________ 5________ 6________ 7________ 8________ 9________ 10_______ 11_______
中等文本(六行)。
进一步编辑:
缩短字符串表明它正在切断最后一两行。可能像Android: Last line of textview cut off。在字符串文件中添加换行符会给我另一行,但不是整个字符串!
【问题讨论】:
-
您能否添加更多代码部分,例如您的所有 LinearLayout 代码。
-
请张贴你的问题的截图