
在我的应用程序的信息区域中,我想显示我的应用程序的简要说明.为此,我需要创建一个包含大量文本的视图.最佳做法是什么?实际上我用ScrollvIEw创建了一个线性布局,在这里我将添加我的文本,其中还应包含一些变量值,例如:我的应用版本.但我不知道是否有更好的方法可以做到这一点?
这是我目前的做法:
<linearLayout androID:ID="@+ID/information_content" androID:layout_wIDth="fill_parent" androID:layout_height="fill_parent" androID:layout_above="@ID/bottom_footer" androID:layout_below="@ID/top_header" androID:layout_marginleft="@dimen/marginleft" androID:layout_alignParentRight="true" androID:layout_weight="1" androID:orIEntation="vertical" > <ScrollVIEw androID:ID="@+ID/scrollVIEw1" androID:layout_wIDth="match_parent" androID:layout_height="wrap_content" > <linearLayout androID:layout_wIDth="match_parent" androID:layout_height="match_parent" androID:orIEntation="vertical" > <EditText androID:ID="@+ID/info_text" androID:layout_wIDth="match_parent" androID:layout_height="wrap_content" androID:ems="10" androID:inputType="textMultiline" androID:text="Hallo das ist ein test!!! dsf" /> </linearLayout> </ScrollVIEw> </linearLayout>有什么建议?
谢谢
解决方法:
您可能正在寻找一个典型的“关于屏幕”,其中包含可以使用HTML格式化的简单可滚动文本.
首先,这是布局/layout/about_layout.xml.您不需要将视图包装在额外的linearLayout中.
<?xml version="1.0" enCoding="utf-8"?><ScrollVIEw xmlns:androID="http://schemas.androID.com/apk/res/androID" androID:layout_wIDth="fill_parent" androID:layout_height="fill_parent" > <relativeLayout androID:layout_wIDth="fill_parent" androID:layout_height="wrap_content" androID:padding="12dp" > <TextVIEw androID:ID="@+ID/about_text_vIEw" androID:layout_wIDth="wrap_content" androID:layout_height="wrap_content" /> </relativeLayout></ScrollVIEw>然后,将以下内容添加到/values/strings.xml中:
<string name="about_text"> <![cdaTA[ Author: Your name<br/><br/>Your description text, changelog, licences etc... ]]></string>最后,使用AboutActivity.java中的布局,显示HTML格式的字符串,并使用一些自动更新的信息(例如版本号)来丰富它.
protected voID onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentVIEw(R.layout.about_layout); String versionname = ""; try { PackageInfo pinfo = getPackageManager().getPackageInfo(getPackagename(), 0); versionname = pinfo.versionname; } catch (nameNotFoundException e) { // Todo auto-generated catch block e.printstacktrace(); } TextVIEw aboutTextVIEw = (TextVIEw) findVIEwByID(R.ID.about_text_vIEw); aboutText = HTML.fromHTML("<h1>Your App name, Version " + versionname + "</h1>" + getString(R.string.about_text)); aboutTextVIEw.setText(aboutText);}这就是我在我的应用程序中处理关于屏幕的方式.对不起,这个答案可能有点过头了,但我认为这是一个常见的模式.
总结以上是内存溢出为你收集整理的在android视图中显示大文本数据的最佳实践?全部内容,希望文章能够帮你解决在android视图中显示大文本数据的最佳实践?所遇到的程序开发问题。
如果觉得内存溢出网站内容还不错,欢迎将内存溢出网站推荐给程序员好友。
欢迎分享,转载请注明来源:内存溢出
微信扫一扫
支付宝扫一扫
评论列表(0条)