In my information area of my app I want to show a brief description of my app. For that I need to create a view with a lot of text. What is the best practice for that ? Actu
You are probably looking for a typical "About Screen" with simple scrollable text that may be formatted using HTML.
Firstly, here is the layout /layout/about_layout.xml
. You don't need to wrap your view in an extra LinearLayout.
Afterwards, add the following to your /values/strings.xml
:
Your description text, changelog, licences etc... ]]>
Finally, use the layout in your AboutActivity.java
, display the string HTML-formatted and enrich it with some auto-updated information, such as your version number.
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("Your App Name, Version " + versionName + "
"
+ getString(R.string.about_text));
aboutTextView.setText(aboutText);
}
That's how I deal with the About Screen in my app. Sorry for this answer might be a bit over the top, but I think it's a commonly requested pattern.