🔥 ۴۰ درصد تخفیف ثبت‌نام دوره‌ها قبل از افزایش قیمت‌ها
۰ ثانیه
۰ دقیقه
۰ ساعت
۶ آریامن ادیانی
افزودن استایل در فایل تم
جامعه کاتلین ایجاد شده در ۱۵ بهمن ۱۴۰۲

سلام
توی فایل تم وقتی میخوام name رو مقداردهی کنم هیچ پیشنهادی نمیده و وقتی هم خودم مینویسم روی ویجت‌ها اعمال نمیشه استایلم 
راه حل این مشکل چیه؟
 

سلام وقت بخیر

ساختار تعریفی داخل فایل تم بصورت زیر هست

به اسم تگ دقت کنید که حتما باید item باشد

<item name="">value</item>
آریانا سلامت ۱۵ بهمن ۱۴۰۲، ۰۸:۵۸
آریامن ادیانی ۱۵ بهمن ۱۴۰۲، ۱۳:۴۱

من عکس کدم رو میفرستم اما ارسال نمیشه ظاهراً

 

آریامن ادیانی ۱۵ بهمن ۱۴۰۲، ۱۳:۴۲

مثل من تو قالب کد بفرستین

آریانا سلامت ۱۶ بهمن ۱۴۰۲، ۰۷:۰۵
    <style name="Base.Theme.BMICalculator" parent="Theme.MaterialComponents.Light.NoActionBar">
        <!-- Customize your light theme here. -->
<!--         <item name="colorPrimary">@color/my_light_primary</item>-->
    </style>
    <style name="Theme.BMICalculator" parent="Base.Theme.BMICalculator" />
    <item name="radioButtonStyle" type="style"> @style/Widget.BMICalculator.CompoundButton.RadioButton </item>
    <item name="switchStyle" type="style"> @style/Widget.BMICalculator.CompoundButton.Switch </item>
    <item name="textViewStyle" type="style"> @style/Widget.BMICalculator.TextView </item>
    <item name="textInputStyle" type="style"> @style/Widget.MaterialComponents.TextInputLayout.OutlinedBox </item>
Style    این هم مال فایل 
  <style name="Widget.BMICalculator.TextView" parent="Widget.MaterialComponents.TextView">
<!--attribute-->
    <item name="android:minHeight">@dimen/min_height</item>
    <item name="android:gravity">center</item>
    <item name="android:textAppearance">?attr/textAppearanceBody1</item>
<!--attribute-->
    </style>
    <style name="Widget.BMICalculator.CompoundButton.Switch" parent="Widget.MaterialComponents.CompoundButton.Switch">
        <item name="android:gravity"> center_vertical </item>
        <item name="android:minHeight"> @dimen/min_height </item>
    </style>
    <style name="Widget.BMICalculator.CompoundButton.RadioButton" parent="Widget.MaterialComponents.CompoundButton.RadioButton">
        <item name="android:textAppearance">?attr/textAppearanceBody2</item>
    </style>
آریامن ادیانی ۱۶ بهمن ۱۴۰۲، ۰۷:۴۱

آیتم‌های style باید داخل یک parent قرار بگیرن

بنابراین آیتم‌های style را داخل تگ style یی که تم اپلیکیشن هست قرار بدین

<resources xmlns:tools="http://schemas.android.com/tools">
    <!-- Base application theme. -->
    <style name="Base.Theme.BMICalculator" parent="Theme.Material3.DayNight.NoActionBar">
        <!-- Customize your light theme here. -->
        <!-- <item name="colorPrimary">@color/my_light_primary</item> -->
        <item name="radioButtonStyle" type="style"> @style/Widget.BMICalculator.CompoundButton.RadioButton </item>
        <item name="switchStyle" type="style"> @style/Widget.BMICalculator.CompoundButton.Switch </item>
        <item name="textViewStyle" type="style"> @style/Widget.BMICalculator.TextView </item>
        <item name="textInputStyle" type="style"> @style/Widget.MaterialComponents.TextInputLayout.OutlinedBox </item>
    </style>
    <style name="Theme.BMICalculator" parent="Base.Theme.BMICalculator" />
</resources>
آریانا سلامت ۱۸ بهمن ۱۴۰۲، ۰۸:۱۲