Android Studio小技巧

Android Studio Tips of the Day里面一共有八十几个。大家可以去查看完整的。而且是持续更新状态中。很有用(记得安全上网,翻墙哦。)

1、tools:attribute

如果你需要查看写的TextView在有文字时候的预览情况。那么这个就是为你准备的。使用'tools:something="value"'这个值会显示在预览时候,但是在软件真正运行的时候不会出现这个内容。
只需要二步就可以:

  • 在根布局中添加xmlns:tools="http://schemas.android.com/tools"

  • 在TextView中使用'tools:something="value"'属性

(这个太有用了!!!我以前每次写布局预览效果都用android:text = "XXX",然后程序弄完还得去删。太傻了!!!)

2、Extract Resource

比如你在布局文件或者代码文件中直接写了某个String字符串或者某个dimen数值,而不是引用资源文件,那难道还要我再去打开相应的String.xml或者dimen.xml文件去添加,然后这边的布局文件或者代码文件中再去修改使用引用?答案当然是NO。
* Mac:选中那个值,然后option+enter键选择Extract String/Dimension Resource 。
* Win: alt+enter键选择Extract String/Dimension Resource 。

3、Toggle between text/design mode

Design查看和Text编辑之间切换
* mac用Control + Shift +左/右
* Windows和Linux上用ALT + SHIFT +左/右

4、CamelHumps

在"Editor->General->Smart Keys"中启动"CamelHumps"功能选项,就可以在连在一起的几个大写为首的单词间快速切换。
* Mac上是option+左右键。
* win上为 "alt" or "ctrl" 键。(这里会有个bug,开启后,比如你的变量名是几个单词,比如是isSuccess,这时候你双击想选中这个变量就发现不能全部选中,就变成选中Success了。)

5、Close Others

当Android Studio开了很多文件,想要留下当前文件,然后关闭其他文件,通常做法是右键,然后选择Close Others。实际上只需要
* Mac:按住option,然后鼠标点击要留下来的文件的关闭按钮,然后其他的就都关闭了
* Win:按住alt.

6、The Navigation Bar

导航栏是在IDE顶部的“面包屑”。
这表明你的路径添加到当前文件,但你也可以用它来导航和/或采取对文件和文件夹的操作。

  • 您可以导航到父母的子文件夹或找到兄弟类
  • 您可以轻松地创建使用代码生成快捷方式(CMD + N / ALT +插入)新文件
  • 事实上,你可以在项目视图通过右键点击做任何事情
  • 你可以隐藏这个导航栏。通过快捷键来显示。可以让Android Studio的屏幕显示内容可以更多。

7、Open Source in New Window

你能让当前打开的文件,以另起一个窗口来进行显示。
* Mac:shift +F4(有些人F4可能是系统快捷键,那就多加一个fn)
* Win:shift+F4

8、Override Methods

我们可能想重载某个父类的方法,但是一时间忘记了这个方法的名字,可以快捷键调出所有可重载的方法,进行选择。
* Mac:control + o
* Win:ctrl + o

9、Edit Regex

描述:使用Java编写正则表达式是一件很困难的事,主要原因是:

  • 你必须得避开反斜杠;
  • 说实话,正则很难;
  • 看第二条。
    IDE能帮我们干点啥呢?当然是一个舒服的界面来编写和测试正则啦~ - 快捷键:Alt + Enter → check regexp

10、The Switcher

打开的文件太多。怎么快速切换文件?
* Mac : control + tab
* win: ctrl + tab

评论

  • ที่นอน回复

    Hello, i read your blog from time to time and i own a
    similar one and i was just curious if you get a lot of spam comments?
    If so how do you reduce it, any plugin or anything you can suggest?

    I get so much lately it's driving me mad so any help is very much appreciated.

  • Adidas NMD Men Women Mesh Surface Dark Olive Green回复

    I really wanted to develop a quick note in order to thank you for all of the fabulous facts you are posting on this site. My extended internet investigation has at the end of the day been paid with incredibly good know-how to talk about with my friends and family. I 'd say that many of us site visitors actually are very blessed to exist in a fine community with many marvellous people with beneficial principles. I feel very blessed to have used your entire webpages and look forward to tons of more fun minutes reading here. Thanks a lot once more for a lot of things.

  • VladilenGergo回复

    why should male take viagra

    <a href=http://viagraomz.com/>cheap viagra</a>

    <a href="http://viagraomz.com/">buy viagra</a>

    compra de viagra online

  • tercio borlenghi junior回复

    I'm not sure why but this weblog is loading extremely slow for me. Is anyone else having this issue or is it a issue on my end? I'll check back later on and see if the problem still exists.|

  • LenaGergo回复

    viagra online australia net

    <a href=http://norxcheapviagraf.com/>generic viagra online</a>

    <a href="http://norxcheapviagraf.com/">cheap viagra</a>

    topaz.mediche viagra

  • general endowment 3.50 minimum gpa回复

    Hello! I could have sworn I've been to this website before but after browsing through some of the post I realized it's new to me.
    Nonetheless, I'm definitely happy I found it and I'll be book-marking
    and checking back often!

  • Law School回复

    Thanks , I have recently been searching for info about this topic for a while and yours is the greatest I've discovered till now. But, what in regards to the conclusion? Are you positive about the source?

  • Real Estate回复

    Thank you, I've recently been looking for information approximately this topic for ages and yours is the greatest I've discovered till now. But, what about the conclusion? Are you sure concerning the supply?

  • air yeezy回复

    I must get across my gratitude for your kindness giving support to those who require assistance with this important niche. Your special dedication to passing the message along turned out to be rather important and have in most cases permitted employees much like me to get to their endeavors. Your entire interesting guidelines can mean a lot a person like me and substantially more to my colleagues. Regards; from all of us.

  • makii miracle回复

    You can certainly see your skills in the article you write.
    The world hopes for more passionate writers like you who are not afraid to mention how they believe.
    At all times follow your heart.

  • กำจัดปลวก回复

    I blog quite often and I genuinely thank you for your information. The article has truly peaked my interest.
    I'm going to take a note of your site and keep checking for new details
    about once a week. I opted in for your RSS feed too.

  • โรงงานผลิตครีม回复

    I like the helpful info you provide in your articles.
    I will bookmark your blog and check again here regularly.
    I'm quite sure I will learn plenty of new stuff right here!
    Best of luck for the next!

  • tuberculosis y embarazo pdf回复

    I'm not sure why but this web site is loading
    very slow for me. Is anyone else having this issue or is it
    a problem on my end? I'll check back later on and see if the problem still exists.

  • termites w wings回复

    Pretty portion of content. I just stumbled upon your
    site and in accession capital to assert that I get actually enjoyed account your
    weblog posts. Any way I'll be subscribing to your augment or even I
    success you access consistently quickly.

  • รักษารากฟัน回复

    Unquestionably believe that which you said.
    Your favorite justification appeared to be on the net the easiest thing to be aware
    of. I say to you, I certainly get annoyed while people think about worries that
    they just don't know about. You managed to hit the nail upon the top as well as defined out the whole thing without having side-effects , people could take
    a signal. Will probably be back to get more. Thanks

  • ขายเสื้อยืด回复

    Hello just wanted to give you a quick heads up and
    let you know a few of the images aren't loading properly.

    I'm not sure why but I think its a linking issue. I've tried
    it in two different browsers and both show the same outcome.

  • เทพทันใจ回复

    When I initially commented I clicked the "Notify me when new comments are added" checkbox and now each time a comment
    is added I get three emails with the same comment.
    Is there any way you can remove people from that service?
    Many thanks!

  • เบอร์มงคล回复

    I'm not sure the place you're getting your info, but great topic.
    I needs to spend a while learning much more or figuring out more.
    Thanks for excellent info I was in search of this info for my mission.

  • prostate cancer lump回复

    Hello all, here every person is sharing these kinds of familiarity,
    thus it's good to read this blog, and I used to visit this
    blog every day.

  • exercicios dengue 6 ano回复

    Everyone loves what you guys are up too. This type of clever work and reporting!
    Keep up the good works guys I've included you guys to
    blogroll.

  • Xvideo回复

    although web-sites we backlink to beneath are considerably not connected to ours, we feel they may be really really worth a go through, so have a look

  • ประกันสุขภาพ回复

    Hi there! I could have sworn I've been to this blog before but after looking at many of the articles I realized it's new to me.
    Nonetheless, I'm certainly pleased I found it and I'll be book-marking it and checking back regularly!

  • e+s sunglasses回复

    Do you mind if I quote a couple of your articles as long as I provide credit and sources back to your website?
    My website is in the exact same niche as yours and my users would genuinely benefit from a lot of the information you
    provide here. Please let me know if this okay with you. Appreciate it!

  • VladilenGergo回复

    cheap viagra 800mg

    <a href=http://viagraomz.com/>buy generic viagra</a>

    <a href="http://viagraomz.com/">generic viagra online</a>

    viagra 100mg erection

  • AdamGergo回复

    cialis40mg discount

    http://canadianiucialis.com/ - cialis cheap

    <a href="http://canadianiucialis.com/">cialis</a>

    cialis 20 mg and cialis 50 mg

  • Itamar Serp回复

    After I originally commented I appear to have clicked the -Notify me when new comments are added- checkbox and now whenever a comment is added I receive 4 emails with the exact same comment. There has to be an easy method you can remove me from that service? Kudos!|

  • rhinoplasty in mexico回复

    Wow, awesome blog layout! How long have you been blogging for?
    you made blogging look easy. The overall look of your web
    site is fantastic, as well as the content!

  • AdamGergo回复

    lilly cialis uk

    http://canadianiucialis.com/ - order cialis online

    <a href="http://canadianiucialis.com/">canadian cialis</a>

    how well does cialis 5 mg work

  • AdamGergo回复

    online cialis 20mg

    http://canadianiucialis.com/ - cialis cheap

    <a href="http://canadianiucialis.com/">cialis</a>

    cialis suave generico

  • สเต็มเซลล์回复

    of course like your web-site but you have to test the
    spelling on several of your posts. A number
    of them are rife with spelling problems and I find
    it very troublesome to tell the reality however I'll definitely
    come back again.

  • แว่นตา回复

    This is very interesting, You're a very skilled blogger.
    I've joined your feed and look forward to seeking more of your excellent post.
    Also, I've shared your website in my social networks!

  • thread face lift youtube回复

    I visited many web pages except the audio feature for audio songs existing at this web page is
    actually superb.

  • sleep aids回复

    Hello there, You have done a fantastic job. I will certainly digg it and personally suggest
    to my friends. I'm sure they'll be benefited from this web site.

  • k palette eyebrow tattoo回复

    Hi there very cool blog!! Guy .. Beautiful .. Superb ..
    I'll bookmark your web site and take the feeds also? I am satisfied to seek out so many useful info right
    here within the submit, we need work out extra techniques on this regard, thanks for sharing.
    . . . . .

  • Sunglasses and bracelets回复

    Thanks for sharing excellent informations. Your website is very cool. I am impressed by the details that you have on this site. It reveals how nicely you perceive this subject. Bookmarked this web page, will come back for more articles. You, my pal, ROCK! I found simply the information I already searched everywhere and just could not come across. What a perfect web site.

  • Minerals for fitness回复

    I really appreciate this post. I¡¦ve been looking all over for this! Thank goodness I found it on Bing. You've made my day! Thank you again

  • Garage home design回复

    hello there and thank you for your information – I’ve definitely picked up anything new from right here. I did however expertise a few technical points using this web site, since I experienced to reload the site a lot of times previous to I could get it to load properly. I had been wondering if your hosting is OK? Not that I am complaining, but sluggish loading instances times will often affect your placement in google and could damage your high quality score if ads and marketing with Adwords. Well I am adding this RSS to my e-mail and could look out for a lot more of your respective exciting content. Make sure you update this again very soon..

  • Cleansers skin care回复

    I wanted to create you this little bit of observation so as to thank you very much over again regarding the fantastic techniques you've documented in this case. It is so seriously open-handed with people like you to convey openly exactly what many of us might have advertised as an e book to end up making some bucks for themselves, most importantly considering that you could possibly have done it if you ever desired. The good ideas likewise worked like the easy way to comprehend many people have similar eagerness just like mine to realize whole lot more on the subject of this matter. I'm sure there are lots of more enjoyable occasions in the future for folks who looked at your blog post.

  • http://kompoz.me回复

    Someone necessarily assist to make significantly articles I'd state.
    This is the first time I frequented your website page and
    thus far? I amazed with the analysis you made to make this particular
    submit incredible. Magnificent process!

  • further wireless sensors回复

    What's up colleagues, how is the whole thing, and what you would like to
    say on the topic of this post, in my view its actually
    amazing designed for me.