官术网_书友最值得收藏!

Creating the category chooser

The category chooser is where the user will select how to file their expense claims. There'll be a fairly small number of these, and they will be represented by icons in the user interface. Fortunately for Android developers, Material specifies a huge range of standard icons, and Android Studio has features to import them as bitmap or vector graphics files. When deciding whether to use bitmap images or SVGs, it's important to consider the trade-off between these two formats, specifically in relation to Android. Especially so since in Android, multiple copies of a bitmap are often provided for different screen sizes and densities, leading to much higher-quality scaling (as most will only ever be scaled down slightly). Here's a quick table to compare them:

For the category chooser widget, you'll be importing vector graphics icons and using them as radio buttons. Let's get things started:

  1. In the files view to the extreme left of Android Studio, right-click on the res directory and select New, Vector Asset to open the vector import tool:
  1. Where it says Icon, click on the button with the Android robot.
  2. Use the search box at the top-left of the dialog to find the "hotel" icon, and select it.
  3. Click on OK to return to the import tool.
  4. The import tool will have changed the proposed name to ic_hotel_black_24dp; change this to ic_accommodation_black:
  1. In the Size boxes, select the Override checkbox and change the size to 32 dp X 32 dp.
  1. Click on Next and then on Finish to complete the import.
  2. Repeat this process, and find the room service icon. Name this one ic_food_black, and don't forget to change its size to 32 dp X 32 dp.
  3. Repeat this for the airport shuttle icon. This is ic_transport_black, and again, change its size to 32 dp X 32 dp.
  4. Repeat and find the local movies icon; name this ic_entertainment_black and remember to change its size to 32 dp X 32 dp.
  5. Find the "business center" icon and name it ic_business_black; again, change its size to 32 dp X 32 dp.
  6. Finally, find the all inclusive icon, name it ic_other_black, and override its size to 32 dp X 32 dp.

Now you have a collection of black icons that will serve as the basis for your category selector.

主站蜘蛛池模板: 炉霍县| 休宁县| 庆云县| 伊宁县| 曲靖市| 和田市| 大渡口区| 达日县| 宁陕县| 桑日县| 府谷县| 固原市| 根河市| 萨嘎县| 江北区| 桐乡市| 乌鲁木齐县| 卓尼县| 武穴市| 观塘区| 磐石市| 宁晋县| 邵阳县| 西宁市| 景宁| 南川市| 从江县| 阜平县| 怀宁县| 清镇市| 葵青区| 岳普湖县| 固始县| 永川市| 赣州市| 雅江县| 广平县| 鞍山市| 静乐县| 新巴尔虎左旗| 全南县|