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

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.

主站蜘蛛池模板: 定陶县| 平江县| 武夷山市| 渑池县| 彩票| 金门县| 巴马| 永平县| 开鲁县| 沅陵县| 基隆市| 武夷山市| 成武县| 赤壁市| 扶风县| 江源县| 榕江县| 武定县| 读书| 漾濞| 五家渠市| 宿州市| 正镶白旗| 新安县| 梁平县| 思南县| 大理市| 桐城市| 扎兰屯市| 金平| 兴业县| 和顺县| 德庆县| 长乐市| 萨嘎县| 东平县| 德格县| 扬州市| 太保市| 大田县| 临颍县|