Wikimedia

Commons Android App: The xml files contain a lot of hardcoded dimensions

Currently, the xml files of the app contain a lot of hardcoded dimensions. Hardcoded dimensions refer to dimensions like:

android:layout_height="20dp"

This will be there for layout_width, margins, textsize and paddings too.

The correct way to do this is to declare the dimension in the dimens.xml file and use it wherever needed.

In the dimens file, a resource can generally be declared as:

<dimen name="medium_height">20dp</dimen>

Once it is declared in the dimens.xml file, the correct way to use in as layout height wherever needed is:

android:layout_height="@dimen/medium_height">

Codebase: https://github.com/commons-app/apps-android-commons

A quickstart guide for developers: https://github.com/commons-app/apps-android-commons/wiki/Quick-start-guide-for-Developers

Task tags

  • xml
  • android

Students who completed this task

alcarazzam

Task type

  • code Code
  • done_all Quality Assurance
close

2019