Read the notes after some experience sharing on the first development of Android TV set (STB)

Source: Internet
Author: User

Original: http://blog.csdn.net/tanghongchang123/article/details/52982818

First, the basic command:

1. ADB connect [IP]

2. ADB disconnect [IP]

3. ADB uninstall [Package]

4. ADB shell Input Text * * *: Used to enter text, in the debugging program, in many cases to type text, mobile phone input convenient, TV, with the remote control by the keyboard very troublesome, you can use this command.

Second, focus control

1. Control whether the control can get focus

android:focusable="True/false" when this property is set to True, indicates that the current control can have the focus, or vice versa. You can also set it through code in your program:

V.setfocusable (true/false);

2, control the remote control by the left and right of the current one to get focus

      • android:nextfocusup=
      • android:nextfocusdown= "@+ ID/... " 
      • android:nextfocusleft= "@+id/..."  
      • android: Nextfocusright= "@+id/..."  
      • The following is a program setting
      • v.setnextfocusup (ID);  
      • v.setnextfocusdown (ID);
      • V.setnextfocusright (ID);  

V.setnextfocusright (ID);

3, TV resolution of the adaptation problem

If the adaptation is not correct, an oom (out of memory) problem is prone to occur. According to the existing TV situation, the general recommended setting

Drawable-sw1080dp

Drawable-sw720dp

Correspondingly, the size of the corresponding resolution is provided:

Values-sw1080dp

Values-sw720dp

For example the same is 1080P, some 32 inches, some 42 inches. Small size, high dpi, so that the picture will be compressed. In the values file, you can use the DP, PIX, and the default DPI is 160. You can also consider the values using PX verification.

4, Shadow, reflection of the program implementation (completely can be implemented by the art, here the code for reference only)

Reflection principle: Basically is the original image inverted, painted on the canvas, and then add a translucent mask.

Shadow effect: There are a lot of tutorials on the web that tell you about shadows, and what you do here is a shadow effect around the picture of a rounded rectangle. The way to do this is to add a rectangular shadow to each of the original edges, and then draw a fan shadow at four rounded corners.

  1. /**
  2. * @author: Sunnybaby
  3. * @Title: Createshadowbitmap
  4. * @Description: Generate shaded picture
  5. * @param orignalbitmap: Original
  6. * @param shadowmargin: Shadow Edge width
  7. * @param Iconcornerradius: Original fillet radius
  8. * @return: Generated shaded picture
  9. */
  10. public static Bitmap Createshadowbitmap (Bitmap orignalbitmap,
  11. int shadowmargin, int iconcornerradius) {
  12. int w = orignalbitmap.getwidth ();
  13. int h = orignalbitmap.getheight ();
  14. Bitmap Shadowbitmap = bitmap.createbitmap (w + shadowmargin * 2, H
  15. + Shadowmargin * 2, config.argb_8888);
  16. int width = shadowbitmap.getwidth ();
  17. int height = shadowbitmap.getheight ();
  18. Canvas canvas = new Canvas (SHADOWBITMAP);
  19. Canvas.drawbitmap (Orignalbitmap, Shadowmargin, shadowmargin, null);
  20. Paint paint = new paint ();
  21. Paint.setxfermode (new Porterduffxfermode (Mode.dst_over));
  22. int radius = shadowmargin + Iconcornerradius;
  23. //four Edge shadow effect with linear shading, width equal to shadow margin + fillet radius
  24. LinearGradient leftgradient = new LinearGradient (radius, 0, 0, 0,
  25. 0x7f000000, 0x00000000, Tilemode.clamp);
  26. LinearGradient rightgradient = new LinearGradient (Width-radius, 0,
  27. width, 0, 0x7f000000, 0x00000000, Tilemode.clamp);
  28. LinearGradient topgradient = new LinearGradient (0, radius, 0, 0,
  29. 0x7f000000, 0x00000000, Tilemode.clamp);
  30. LinearGradient bottomgradient = new LinearGradient (0, Height-radius,
  31. 0, height, 0x7f000000, 0x00000000, Tilemode.clamp);
  32. Paint.setshader (leftgradient);
  33. Canvas.drawrect (0, radius, radius, Height-radius, paint);
  34. Paint.setshader (rightgradient);
  35. Canvas.drawrect (Width-radius, radius, width, Height-radius, paint);
  36. Paint.setshader (topgradient);
  37. Canvas.drawrect (RADIUS, 0, Width-radius, radius, paint);
  38. Paint.setshader (bottomgradient);
  39. Canvas.drawrect (RADIUS, Height-radius, Width-radius, height, paint);
  40. //Four-corner shadow effect with circular shading, radius equal to shadow margin + fillet radius
  41. Radialgradient topleftcornergradient = new Radialgradient (RADIUS,
  42. Radius, radius, 0x7f000000, 0x00000000, Tilemode.clamp);
  43. Radialgradient toprightcornergradient = new Radialgradient (width
  44. -Radius, radius, radius, 0x7f000000, 0x00000000,
  45. Tilemode.clamp);
  46. Radialgradient bottomleftcornergradient = new Radialgradient (RADIUS,
  47. Height-radius, Radius, 0x7f000000, 0x00000000, Tilemode.clamp);
  48. Radialgradient bottomrightcornergradient = new Radialgradient (width
  49. -Radius, Height-radius, radius, 0x7f000000, 0x00000000,
  50. Tilemode.clamp);
  51. //Draw four corner, is to draw four circle center angle is 90 degrees of the fan, DrawArc function The first parameter is the circular circle of the external rectangle, the second parameter is the starting angle, the third parameter is a sector clockwise glide angle, the fourth parameter if True, Include the center of the circle when the arc is drawn (to draw a fan), and the fifth parameter is a brush
  52. Paint.setshader (topleftcornergradient);
  53. Canvas.drawarc (new RECTF (0, 0, Radius * 2, RADIUS * 2),
  54. Paint);
  55. Paint.setshader (toprightcornergradient);
  56. Canvas.drawarc (new RECTF (Width-radius * 2, 0, Width, radius * 2),
  57. (+ ), N, true, paint);
  58. Paint.setshader (bottomleftcornergradient);
  59. Canvas.drawarc (new RECTF (0, Height-radius * 2, RADIUS * 2, height),
  60. (A );
  61. Paint.setshader (bottomrightcornergradient);
  62. Canvas.drawarc (new RECTF (Width-radius * 2, Height-radius * 2,
  63. width, height), 0, N, true, paint);
  64. return shadowbitmap;
  65. }

Read the notes after some experience sharing on the first development of Android TV set (STB)

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.