in car_app_library/showcase/common/src/main/java/androidx/car/app/sample/showcase/common/misc/ColorDemoScreen.java [47:129]
public Template onGetTemplate() {
ItemList.Builder listBuilder = new ItemList.Builder();
listBuilder.addItem(
new Row.Builder()
.setTitle("Example 1")
.addText(Utils.colorize("This text has a red color", RED, 16, 3))
.setImage(new CarIcon.Builder(
IconCompat.createWithResource(
getCarContext(),
R.drawable.ic_fastfood_white_48dp))
.setTint(RED)
.build())
.build());
listBuilder.addItem(
new Row.Builder()
.setTitle("Example 2")
.addText(Utils.colorize("This text has a green color", GREEN, 16, 5))
.setImage(new CarIcon.Builder(
IconCompat.createWithResource(
getCarContext(),
R.drawable.ic_fastfood_white_48dp))
.setTint(GREEN)
.build())
.build());
listBuilder.addItem(
new Row.Builder()
.setTitle("Example 3")
.addText(Utils.colorize("This text has a blue color", BLUE, 16, 4))
.setImage(new CarIcon.Builder(
IconCompat.createWithResource(
getCarContext(),
R.drawable.ic_fastfood_white_48dp))
.setTint(BLUE)
.build())
.build());
listBuilder.addItem(
new Row.Builder()
.setTitle("Example 4")
.addText(Utils.colorize("This text has a yellow color", YELLOW, 16, 6))
.setImage(new CarIcon.Builder(
IconCompat.createWithResource(
getCarContext(),
R.drawable.ic_fastfood_white_48dp))
.setTint(YELLOW)
.build())
.build());
listBuilder.addItem(
new Row.Builder()
.setTitle("Example 5")
.addText(Utils.colorize("This text uses the primary color", PRIMARY, 19, 7))
.setImage(new CarIcon.Builder(
IconCompat.createWithResource(
getCarContext(),
R.drawable.ic_fastfood_white_48dp))
.setTint(PRIMARY)
.build())
.build());
listBuilder.addItem(
new Row.Builder()
.setTitle("Example 6")
.addText(
Utils.colorize(
"This text uses the secondary color", SECONDARY, 19, 9))
.setImage(new CarIcon.Builder(
IconCompat.createWithResource(
getCarContext(),
R.drawable.ic_fastfood_white_48dp))
.setTint(SECONDARY)
.build())
.build());
return new ListTemplate.Builder()
.setSingleList(listBuilder.build())
.setTitle("Color Demo")
.setHeaderAction(BACK)
.build();
}