这里有一个关于如何最好地处理文本截断的简短问题。当字符串被TextView截断时,你知道向用户显示完整字符串的好方法吗?
任何大小的屏幕都可能剪切TextView中长字符串集的文本。当应用程序支持多种尺寸,特别是普通和大尺寸屏幕时,这个问题变得更加明显。
一个好的建议是使文本视图可滚动。我对这个建议的问题是,我计划在所有四个方向上进行滑动导航交互,这使文本视图滚动变得复杂。我今天在安卓办公时间提出了这个问题。欢迎提出任何建议,特别是基于现有解决方案的建议。提前感谢。。。
这里有一个关于如何最好地处理文本截断的简短问题。当字符串被TextView截断时,你知道向用户显示完整字符串的好方法吗?
任何大小的屏幕都可能剪切TextView中长字符串集的文本。当应用程序支持多种尺寸,特别是普通和大尺寸屏幕时,这个问题变得更加明显。
一个好的建议是使文本视图可滚动。我对这个建议的问题是,我计划在所有四个方向上进行滑动导航交互,这使文本视图滚动变得复杂。我今天在安卓办公时间提出了这个问题。欢迎提出任何建议,特别是基于现有解决方案的建议。提前感谢。。。
解决这个问题的一种方法是在文本视图中添加一个属性,使其在不添加代码的情况下可滚动:
android:lines="3"
android:textIsSelectable="true"
android:fadeScrollbars="false"
这是Android开发者关系团队的一名成员在办公时间提出的建议。然而,经过测试,scroll在Android 2.2.2版本上无法运行。我的新解决方案是声明文本视图可点击,并使用Click回调打开一个对话框。
因此,现在我将文本椭圆化(不再有滚动标签),以便向用户明确指示文本已被截断。以下是xml:
android:lines="3"
android:clickable="true"
android:onClick="showDef"
android:ellipsize="start"
android:isScrollContainer="false"
这是showDef方法:
public void showDef(View v) {
AlertDialog.Builder builder = new AlertDialog.Builder(this);
builder.setMessage("same text as was set in the text view")
.setCancelable(false)
.setNegativeButton("Clear", new DialogInterface.OnClickListener() {
public void onClick(DialogInterface dialog, int id) {
dialog.cancel();
}
});
AlertDialog alert = builder.create();
alert.show()
在包含文本视图的视图组具有固定大小的情况下,我更喜欢这种解决方案,而不是简单的滚动。我希望它对你也有用,。
这里有一个完美的指南,建议您将文本大小调整到相应的屏幕大小在这里你可以找到它。
此外,您还可以在文本视图中使用某些属性;
<TextView android:id="@+id/textView1" android:layout_width="wrap_content" android:layout_height="wrap_content" android:text="Small Text" android:textAppearance="?android:attr/textAppearanceSmall" />
<TextView android:id="@+id/textView1" android:layout_width="wrap_content" android:layout_height="wrap_content" android:text="Medium Text" android:textAppearance="?android:attr/textAppearanceMedium" />
<TextView android:id="@+id/textView2" android:layout_width="wrap_content" android:layout_height="wrap_content" android:text="Large Text" android:textAppearance="?android:attr/textAppearanceLarge" />
你可以用它来截断你的文本:
<TextView
android:id="@+id/textView1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="This is your text"
android:ellipsize="marquee" android:lines="1 />
I m relatively new to Android development. I m developing an app with a ListView. I ve followed the info in #1338475 and have my app recognizing the fling gesture, but after the gesture is complete, ...
I m converting my code from using Handler to AsyncTask. The latter is great at what it does - asynchronous updates and handling of results in the main UI thread. What s unclear to me is how to handle ...
I want to be able to download a file with a particular extension from the net, and have it passed to my application to deal with it, but I haven t been able to figure out the intent filter. The ...
I am quite impressed by the workflow I follow when developing Android applications: Define a layout in an xml file and then write all the code in a code-behind style. Is there an equivalent style for ...
To draw landscapes, backgrounds with patterns etc, we used TiledLayer in J2ME. Is there an android counterpart for that. Does android provide an option to set such tiled patterns in the layout XML?
When following the Android Open Source Project instructions on installing repo for use with Git, after running the repo init command, I run into this error: /c/Users/Andrew Rabon/bin/repo: line ...
I read in the Android documentation that by setting my Activity s launchMode property to singleTop OR by adding the FLAG_ACTIVITY_SINGLE_TOP flag to my Intent, that calling startActivity(intent) would ...
I have pretty good skills in PHP , Mysql and Javascript for a junior developer. If I wanted to try my hand as Android Development do you think I might find it tough ? Also what new languages would I ...