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

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.

主站蜘蛛池模板: 新化县| 仪陇县| 方山县| 澜沧| 新巴尔虎左旗| 和硕县| 奉节县| 凤阳县| 西乌| 左云县| 开原市| 新津县| 邯郸市| 汶上县| 成武县| 株洲县| 阜平县| 集贤县| 天峨县| 湾仔区| 晋城| 宁海县| 商城县| 汾西县| 霍邱县| 通榆县| 邻水| 汉川市| 锦州市| 津南区| 洛南县| 开远市| 阳城县| 奈曼旗| 永和县| 东至县| 通城县| 巴彦县| 新郑市| 眉山市| 乌什县|