ํค์ด๋๋ฌ Resource Convention ์ฐธ๊ณ
| Prefix |
์ค๋ช
|
activity_ |
Activity์์ ์ฐ์ด๋ layout |
fragment_ |
Fragment์์ ์ฐ์ด๋ layout |
dialog_ |
Dialog์์ ์ฐ์ด๋ layout |
view_ |
CustomView์์ ์ฐ์ด๋ layout |
item_ |
RecyclerView, GridView, ListView๋ฑ์์ ViewHolder์ ์ฐ์ด๋ layout |
layout_ |
<include/>๋ก ์ฌ์ฌ์ฉ๋๋ ๊ณตํต์ layout |
-
activity_main: MainActivity์ layout
-
fragment_request: RequestFragment์ layout
-
dialog_contact: ๋ฌธ์์๋ด Dialog์ layout
-
view_rating: ์ปค์คํ
์ผ๋ก ๋ง๋ RatingView์ layout
-
item_my_car: ๋ด์ฐจ๋ ๋ชฉ๋ก์์ ์ฌ์ฉ๋๋ ๊ฐ๊ฐ์ item์ layout
-
layout_dealer_review: ์ฌ์ฌ์ฉ๋๋ ๋๋ฌ๋ฆฌ๋ทฐ layout
<WHAT>_<DESCRIPTION>
- View์ ๋๋ฌธ์๋ฅผ ์ถ์ฝํ์ฌ
<WHAT>์ Prefix๋ก ์ฌ์ฉํ๋ค.
- ์๋ ์ด๋ฆ๊ท์น์ ์ ์ฉํ๋ค.
- Android์ View๋ camel case์ ๋๋ฌธ์๋ฅผ ์ถ์ฝํ ํํ๋ก ์ ํ๋ค.
: TextView -> tv_
- ๋ง์ฝ View์ ์ด๋ฆ์ด Space, Switch์ ๊ฐ์ด 1๊ฐ์ ๋๋ฌธ์๋ง ์กด์ฌํ๋ค๋ฉด ๋ชจ๋ ์๋ฌธ์์ธ ์์ด๋๋ก ์ ํ๋ค.
: Switch -> switch_
- CustomView๋ ์ ์ฒด View์ ์ด๋ฆ์ snake case์ด๋ฆ์ผ๋ก ์ ํ๋ค.
: MyCustomView -> my_custom_view
(๋ง์ฝ 1๊ฐ์ xml์ ๊ฐ์ ์ฌ๋ฌ CustomView๊ฐ ์กด์ฌํ๋ค๋ฉด <WHAT>_<DESCRIPTION>์ ํํ๋ก ์ ํ๋ค.)
| View |
Prefix |
| TextView |
tv_ |
| ImageView |
iv_ |
| CheckBox |
cb_ |
| RecyclerView |
rv_ |
| EditText |
et_ |
| ProgressBar |
pb_ |
| FrameLayout |
fl_ |
| NestedScrollView |
nsv_ |
| Space |
space_ |
| Switch |
switch |
| AbcDeFgh |
adf_ |
| Abcdef |
abcdef_ |
| Toolbar |
toolbar_ |
| MyCustomView |
my_custom_view |
| YourView |
your_view |
- ํด๋น View๋ฅผ ํน์ ๊ธฐ๋ฅ๊ณผ ์๊ด์์ด
VISIBLE/GONE๋ฑ์ View์ ์ฉ๋๋ก ์ฌ์ฉํ๋ค๋ฉด view_xxx๋ก ์ฌ์ฉํ๋๊ฒ๋ ํ์ฉํ๋ค.
-
iv_close: ๋ซ๊ธฐ ImageView
-
tv_select: ์ ํ TextView
-
rv_car_list: ์๋์ฐจ ๋ชฉ๋ก RecyclerView
-
view_etc_model: ๊ธฐํ ๋ชจ๋ธ ํ๋ฉด LinearLayout
<WHAT>_<DESCRIPTION>(_<WHERE>)(_<SIZE>)
- ๊ฒน์น๋ ๊ฒฝ์ฐ ๋ค์ where ์ถ๊ฐ
- ํ์ํ ๊ฒฝ์ฐ size ์ถ๊ฐ
| Prefix |
์ค๋ช
|
btn_ |
๋ฒํผ์ผ๋ก ์ฐ์ด๋ ์ด๋ฏธ์ง |
ic_ |
์์ด์ฝ ํํ์ ์ด๋ฏธ์ง |
bg_ |
๋ฐฑ๊ทธ๋ผ์ด๋ ์์, radius ์ ํ๋ ํ์ผ |
img_ |
์ค์ ์ฌ์ง์ด๊ฑฐ๋ ์์ด์ฝํํ๊ฐ ์๋ ์ผ๋ฌ์คํธํํ์ ์ด๋ฏธ์ง |
div_ |
divider๋ก ํ์ฉ๋๋ ์ด๋ฏธ์ง |
selector_ |
selector๋ก ํ์ฉ๋๋ ํ์ผ |
- ๋ฐฐ๊ฒฝ์ด white์์ 24dp๋ก ํ
๋๋ฆฌ๋ฅผ ๊ทธ๋ฆฌ๋ ๊ฒฝ์ฐ๋
bg_white_radius_24dp.xml๋ก ํ๋ค.
- ๋ฐฐ๊ฒฝ์ด ํฌ๋ช
ํ๋ฉฐ ๋ฐฐ๊ฒฝ์ ์ ๋ง์ sky_blue์์ 8dp๋ก ํ
๋๋ฆฌ๋ฅผ ๊ทธ๋ฆฌ๋ ๊ฒฝ์ฐ๋
bg_stroke_sky_blue_radius_8dp.xml๋ก ํ๋ค.
-
selector_call.xml: ์ ํ๊ฑธ๊ธฐ ์ด๋ฏธ์ง์ selector xml
-
ic_dealer_gift.png: ๋๋ฌ๊ฐ ๋ณด๋ด์ค ๊ธฐํํฐ์ฝ์ ๋ณด์ฌ์ค๋ ํ์๋๋ ์ด๋ฏธ์ง
-
img_splash_chart.png: ์คํ๋์ ํ๋ฉด์์ ๋ณด์ฌ์ง๋ ์ฐจํธ ์ด๋ฏธ์ง
<WHERE>_<DESCRIPTION>_<WHAT>
- ์ฌ๋ฌ ๊ตฐ๋ฐ์์ ์ฌ์ฌ์ฉ๋๋ ๊ฐ๋
์ด๋ผ๋ฉด ๋ณ์๋ก ์ ์ํด์
@dimen/xxx์ ๊ฐ์ด ์ฌ์ฉ
- ๊ทธ๋ ์ง ์๋ค๋ฉด ๋ช
์์ ์ผ๋ก
16dp์ ๊ฐ์ด ์์ฑ
- ๋๋ถ๋ถ์
margin/padding์ ์๋ ์ ์๋ space_xxx๋ก๋ง ์ฌ์ฉ๋๋๋ก ํ๋ค.
<dimen name="space_x_small">8dp</dimen>
<dimen name="space_small">12dp</dimen>
<dimen name="space_median">16dp</dimen>
<dimen name="space_s_large">18dp</dimen>
<dimen name="space_large">20dp</dimen>
<dimen name="space_x_large">24dp</dimen>
- ๊ทธ์ธ์ ํน์ ํ๋ฉด์์ ์์ ๊ฐ์ ๋ฐ๋ฅด์ง ์๋๊ฒฝ์ฐ, ์ ๊ท์น์ผ๋ก ๋ง๋ ๋ค.
<dimen name="register_car_item_car_model_start_padding">40dp</dimen>
<dimen name="register_car_item_grade_start_padding">56dp</dimen>
<dimen name="register_car_item_car_detail_start_padding">72dp</dimen>
- 2๋ฒ ์ด์ ์ฐ์ด๋๊ฒฝ์ฐ๋ dimen์ ์ ์ํด์ฃผ๋ ๊ฒ์ ๊ฐ์ ํ๊ณ 1๋ฒ๋ง ์ฐ์ด๋ ๊ฒฝ์ฐ์๋ xml ์ฝ๋์ ๋ฃ์ด๋ ๊ด์ฐฎ์ ๊ฒ์ผ๋ก ํ๋ค.
- ๋์ด๋ง ์ง์ ํ ๋๋
height, 1:1 ๋น์จ๋ก ๊ฐ์ ๊ฐ์ด ๋ค์ด๊ฐ๋๋ size๋ก ํ๋ค.
<dimen name="toolbar_height">56dp</dimen>
<dimen name="register_input_view_default_height">280dp</dimen>
<dimen name="register_input_view_collapse_height">200dp</dimen>
<dimen name="dealer_profile_image_size">48dp</dimen>
<WHERE>_<DESCRIPTION>
- ํน์ ํ๋ฉด์์ ์ฐ์ด๋ ํ
์คํธ ์๋๋ผ ์ฌ๋ฌ๊ตฐ๋ฐ์์ ๊ณตํต์ผ๋ก ์ฌ์ฌ์ฉ๋ ํ
์คํธ๋ผ๋ฉด
all_<DESCRIPTION>๋ก ์ด๋ฆ์ ์ง๋๋ค.
- where ๋ฐ๋๋ ๋ถ๋ถ์์ ํ ์ค ๋์ฐ๊ธฐ
-
permission_dialog_camera_title: ์นด๋ฉ๋ผ๊ถํ์ ์๊ตฌํ๋ Dialog์ ์ ๋ชฉ
-
permission_dialog_camera_description: ์นด๋ฉ๋ผ๊ถํ์ ์๊ตฌํ๋ Dialog์ ์ค๋ช
๋ด์ฉ
-
all_yes: ๋ค
-
all_ok_understand: ์ฌ๋ฌ Dialog์์ ๋ค, ์๊ฒ ์ต๋๋ค๋ก ์ฐ์ด๋ ๊ณตํต์ ํ
์คํธ
- ๋ฌธ๋จํํ์ ๊ธด ๋ฌธ์์ด๋ก ๊ฐํ(
\\n)์ด ํ์ํ ๊ฒฝ์ฐ, \\n์ ๋ค์์ค์ ์์ ์ด๋ค.
<string name="sample">๋ฌธ๋จ ์ฒซ๋ฒ์งธ์ค
\\n๋ฌธ๋จ ๋๋ฒ์งธ์ค
\\n๋ฌธ๋จ ์ธ๋ฒ์งธ์ค</string>
- 1๋ฒ๋ง ์ฐ์ด๋ ๊ฒฝ์ฐ์๋ style์ ๋ง๋ค์ง ์๋๋ค.
(๋จ, ์์ผ๋ก ์ฌ์ฌ์ฉ๋ ๊ฐ๋ฅ์ฑ์ด ๋์ ๊ฒฝ์ฐ์๋ ๊ฐ๋ฅ)
- style์ ์ด๋ฆ์ parent์ ์ด๋ฆํจํด๊ณผ ๋ง์ถ๋ค.
<style name=โWidget.HeyDealer.Buttonโ parent=โ@style/Widget.AppCompat.Buttonโ>
...
</style>
- parent์์ ์ผ๋ถ ๋ด์ฉ๋ง ์์ ํ๊ณ ์ ํ๋๊ฒฝ์ฐ, parent ์ด๋ฆ ๋ค์ ๋ฌ๋ผ์ง ๋ด์ฉ์ ๋ด์ฉ์ ์ถ๊ฐํด์ค๋ค.
<style name="Theme.HeyDealer.Transparent" parent="Theme.HeyDealer">
...
</style>
- Base Style๊ณผ Theme์ ๊ฒฝ์ฐ๋ ์์
Base๋ฅผ ๋ถ์ธ๋ค.
<style name="Base.Theme" parent="..." />
<style name="Base.Theme.Transparent">...</style>
<style name="HeyDealerTheme" parent="Base.Theme">...</style>
<style name="HeyDealerTheme.Transparent" parent="Base.Theme.Transparent" />
<style name="Base.TextAppearance.HeyDealer" parent="...">...</style>
<style name="Base.TextAppearance.HeyDealer.Headline">...</style>
<style name="TextAppearance.HeyDealer.Headline1" parent="Base.TextAppearance.HeyDealer.Headline">...</style>
<style name="TextAppearance.HeyDealer.Headline2" parent="Base.TextAppearance.HeyDealer.Headline">...</style>
- Attribute์ด๋ฆ์ camel case๋ก ํ๋ค.
<attr name="numStars" format="integer" />
- ๊ธฐ์กด์ ์ ์๋์ด์๋
android:xxx์ ๊ฐ์ ๋์์ ์ ๋ํ๋ ๊ฒฝ์ฐ, ์ด tag๋ฅผ ์ฌ์ฌ์ฉํ๋ค.
<declare-styleable name="SpannedGridLayoutManager">
<attr name="android:orientation" />
...
</declare-styleable>