ခဏလေး ဒီလိုပဲ စဉ်းစားကြည့်
Android project ထဲက `res/` folder အောက်မှာ resource type အလိုက် sub-folder ခွဲထားပါတယ် — `drawable/` (image, icon), `values/strings.xml` (text string, translation-friendly), `values/colors.xml` (color palette)။ String/color ကို hardcode မရေးဘဲ resource file ထဲက reference (`stringResource(R.string.app_name)`) ကို သုံးရင် — app ကို ဘာသာစကား အများ support ဖို့ (localization) ပိုလွယ်ကူပါတယ်.
လက်တွေ့ scenario နဲ့ ချိတ်ကြည့်မယ်
`res/drawable/logo.png` ကို ထည့်ထားရင် Compose ထဲမှာ `Image(painter = painterResource(R.drawable.logo), contentDescription = "App logo")` လို့ ခေါ်သုံးနိုင်ပါတယ် — `contentDescription` ကို accessibility (screen reader) အတွက် ထည့်ပေးသင့်ပါတယ်။ `res/values/strings.xml` ထဲမှာ `<string name="welcome_message">Welcome!</string>` ရေးထားရင် `stringResource(R.string.welcome_message)` နဲ့ Compose ထဲက ခေါ်သုံးနိုင်ပါတယ်.
အတူတူ ကြည့်မယ်
@Composable
fun WelcomeHeader() {
Column(horizontalAlignment = Alignment.CenterHorizontally) {
Image(
painter = painterResource(id = R.drawable.logo),
contentDescription = "App logo",
modifier = Modifier.size(80.dp)
)
Text(text = stringResource(id = R.string.welcome_message))
}
}Logo image ရဲ့ အောက်မှာ strings.xml ကနေ ဆွဲယူထားတဲ့ welcome text ကို screen ပေါ်မှာ တွေ့ရမည်။၅ မိနစ် စမ်းကြည့်
`res/values/strings.xml` ထဲမှာ string resource တစ်ခု ကိုယ်တိုင် ထည့်ရေးပြီး, `stringResource()` နဲ့ Compose ထဲက ခေါ်သုံးကြည့်ပါ။
သတိလေးတစ်ချက်
Large image (high resolution photo) ကို optimize မလုပ်ဘဲ `drawable/` ထဲ တိုက်ရိုက် ထည့်ခြင်း — app size ကြီးလာပြီး, download/install time ကို ထိခိုက်နိုင်ပါတယ် — WebP format သုံးခြင်း/resize လုပ်ခြင်းကို စဉ်းစားပါ။