RSS

paddingLeft vs paddingStart

So, in the last few days, several teammates have asked me what is the difference between paddingLeft and paddingStart. So, I have written this to document my experience.

Why use paddingStart?

paddingRelative, paddingStart and paddingEnd are added in API 17 to support RTL devices. When your phone is switched to a RTL language, every view should be a mirror image of LTR mode.

In a LTR language, paddingStart is on the left and paddingEnd is on the right. In a RTL language (Arabic, Hebrew), it’s the opposite. If you only define paddingLeft and paddingRight and not start and end, then the layout would not be a mirror image in a RTL phone.

LTR

LTR language phone

RTL

RTL language phone

 

When to use paddingStart?

paddingStart and paddingEnd are equivalent to paddingLeft and paddingRight in API 17+ devices. Remember to add paddingStart and paddingEnd in these situations:

  • When paddingLeft and paddingRight are different.
  • Your app needs to support API 17+ devices with RTL.

 

How to use paddingStart and paddingEnd?

  • If paddingLeft and paddingRight are the same, you are done.
  • Otherwise, wherever you see a paddingLeft, put a paddingStart with it, same for right-end.
  • Do not remove paddingLeft and paddingRight from xml file (until the day we decide we will stop supporting API 16- devices).
    <TextView
        android:id="@+id/title"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:paddingTop="@dimen/vertical_padding"
        android:paddingEnd="@dimen/end_padding"
        android:paddingRight=""@dimen/end_padding"
        android:paddingBottom="@dimen/vertical_padding"
        android:paddingStart="@dimen/start_padding"
        android:paddingLeft="@dimen/start_padding" />

Troubleshoot

I used paddingStart and paddingEnd and now QA tells me that my padding is broken in ICS/JB devices.

RTL support is added in API 17, so it’s still necessary to define paddingLeft and paddingRight in your xml. paddingStart and paddingEnd will override those values in API 17+ device.

Ok, it fails the lint test. Are you lying to me?

As I have said in “Why use paddingStart?”, paddingStart (etc) are added in API 17. So it’s normal for lint test to fail. Here’s a few solutions:

  • Equal left and right paddings
    • If left padding is equal to right padding, then we don’t need to define start and end paddings.
  • Suppress the lint error
  • Have a separate style file
    • Define a values-v17 folder
    • Place start and end in values-v17
    • Keep left and right in values.
 
Leave a comment

Posted by on March 19, 2016 in Android App, Uncategorized

 

Tags: , , , , , , ,

Chocolate Tour @ San Francisco

Last weekend I went to San Francisco to stay at Maria’s. We went on the chocolate tour. More pictures, less text. So much fun…

 
Leave a comment

Posted by on January 15, 2014 in Uncategorized

 

How to uninstall HP Utility on a MAC

Got a new Espon printer after my HP dies, but I can’t seem to remove the HP Utility in my LaunchPad… Took a while for me to figure out. (Most of the links I Googled suck.)

Just because HP sucks and it hides its HP Utility app somewhere, doesn’t mean you cannot install the redundant program.

  1. Remove your printer.
    1. Go to “Printers and Scanners”. (I did a quick spotlight search. You can go there through System Preference.)
      pic1
    2. Select your old HP printer and then hit the ‘-‘ sign.
      pic2
  2. Remove the HP folder.
    1. The path is “/Library/Printers/hp”.
      pic3
    2. If you can’t find it, just go to your document. Then from the bottom select “Macintosh HD”. You should be able to navigate your way to the folder.
    3. Move it to Trash.
  3. Remove the gz files in PPDs folder.
    1. The path is “/Library/Printers/PPDs/Contents/Resources”.
      pic4
    2. Delete only the gz files relative to your deleted printer.
  4. Try to look for other HP files in your Library.
    1. I found a few files in Image Capture folder. I believe this  is depending on your printer model.
  5. Delete shortcut in LaunchPad (Applications) folder.
    1. In Finder, open Applications folder.
    2. Under Utilities, you will see the shortcut link to HP Utility.
    3. Delete that too.
  6. Empty Trash.
  7. Run Disk Utility (spotlight search it or find it under Utility in launch pad).
    1. Select Macintost HD
    2. Click on Verify Disk Permission.
    3. When it’s done, click on Repair Disk Permission.
      pic5
  8. Restart your Mac

Now you are done!

 
4 Comments

Posted by on October 29, 2013 in Uncategorized

 

Tags: , , ,

HK Trip 2013 – Day 16 ~ Happy Mother’s Day

Bye bye to Shirley in the morning, got my ma a Samsung Galaxy S III mini for Mother’s Day~~~

 
Leave a comment

Posted by on May 13, 2013 in Travel

 

Tags: , , ,

HK Trip 2013 – Day 15 ~ APM shopping with Shirley

Picked up Shirley from hotel, breakfast, APM, 滙景, got new slippers. Seriously, not much.

 
Leave a comment

Posted by on May 12, 2013 in Travel

 

Tags: , , , ,

HK Trip 2013 – Day 14 ~ Lantau Island

46 fucking pictures… not gonna describe every one of those. Morning at the big buddha, afternoon shopping in the mall by the cable car station, evening with Joanna!!! Guess I only see her once every 4 years!

 
1 Comment

Posted by on May 12, 2013 in Travel

 

Tags: , , , , ,

HK Trip 2013 – Day 13 ~ Macau Day 2

Went to A-Ma Temple, Museum, then Venetian Hotel… then back to HK~

 
Leave a comment

Posted by on May 12, 2013 in Travel

 

Tags: , , , ,