简体   繁体   English

Android TextView停止换行

[英]Android TextView's stopped wrapping text

I spent a ton of time looking for a solution to this but have not found anything that seems similar to what I am experiencing. 我花了很多时间寻找解决方案,但是没有发现任何与我所遇到的相似的东西。 When I run my app on my G2 none of my textviews wrap text.(regardless of how large the views are.) If i run it on an emulator they wrap appropriately. 当我在G2上运行我的应用程序时,我的所有textview都不会换行。(不管视图有多大。)如果我在模拟器上运行,它们会自动换行。 None of my other apps seem to have this problem when deployed to my G2. 部署到我的G2时,其他所有应用程序似乎都没有这个问题。 I have power cycled my devices, recreated layouts, etc. This seems to even affect a standard alert dialog in this particular app. 我关闭了设备的电源,重新创建了布局,等等。这似乎甚至影响了此特定应用程序中的标准警报对话框。 It is happening in all my activities. 这在我所有的活动中都在发生。 Has anyone seen anything like this or does anyone have an idea what I should be looking at? 有没有人看到过这样的东西,或者有人知道我应该看什么?

Some code as requested... 一些要求的代码...

AlertDialog.Builder eula = new AlertDialog.Builder(activity)
            .setTitle(R.string.eula_title)
            .setIcon(android.R.drawable.ic_dialog_info)
            .setMessage(R.string.eula_text)
            .setCancelable(accepted)
            .setPositiveButton(R.string.eula_accept,
                        new android.content.DialogInterface.OnClickListener() {
                            public void onClick(DialogInterface dialog, int which) {
                                setAcceptedEula(activity);
                                dialog.dismiss();
                                mHandler.post(mSplashScreen.launch);
                            }
                        })
            .setNegativeButton(R.string.eula_decline,
                        new android.content.DialogInterface.OnClickListener() {
                            public void onClick(DialogInterface dialog, int which) {
                                dialog.cancel();
                                activity.finish();
                            }
                        });
    eula.show();

Standard alert dialog won't wrap text. 标准警报对话框不会换行。 It shows one line that trails off the view. 它显示了一条拖离视图的线。

OK so i figured it out. 好,所以我想通了。
I have a theme applied to my app with parent theme Theme.Holo . 我有一个主题应用于父主题Theme.Holo

When I removed that theme as the parent my textviews started wrapping again! 当我删除该主题作为父主题时,我的textviews再次开始环绕! I don't know why other then when run on a device that doesn't understand Theme.Holo it got confused. 我不知道为什么在不了解Theme.Holo的设备上运行时会感到困惑。

So I just created an additional values-v13 directory and modified my themes. 因此,我刚刚创建了一个附加的values-v13目录并修改了主题。 Sorry for the trouble folks. 对不起麻烦的人。

In addition to Larry McKenzie answer I had to set corresponding parameters to the TextView: 除了Larry McKenzie的答案,我还必须为TextView设置相应的参数:

android:ellipsize="none"
android:maxLines="20"
android:scrollHorizontally="false"
android:singleLine="false" 

Example: 例:

<TextView                  
  android:textColor="@color/white"
  android:layout_width="wrap_content"
  android:layout_height="wrap_content"
  android:ellipsize="none"
  android:maxLines="20"
  android:scrollHorizontally="false"
  android:singleLine="false"
  android:text="@string/my_text" />

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM