برای تغییرتم material design را در اپلیکیشن اندرویدی که در حال کد نویسی هستید فعال کنید و از آن استفاده کنید و مراحل زیر را اجرا کنید:
برای مثال کد زیر:
dependencies {
compile fileTree(dir: ‘libs’, include: [‘*.jar’])
compile ‘com.android.support:appcompat-v7:23.0.1’
compile ‘com.android.support:design:23.0.1’
}
و این عملیات را در Project Structure میتوان انجام داد
برای مثال:
کتابخانه com.android.support:design:23.1.1 را با فشردن دکمه + از لیست انتخاب کرده و اضافه کرده و پنجره را میبندیم.
colors.xml
<?xml version=”۱.۰″ encoding=”utf-8″?>
<resources>
<color name=”colorPrimary”>#125688</color>
<color name=”colorPrimaryDark”>#125688</color>
<color name=”textColorPrimary”>#FFFFFF</color>
<color name=”windowBackground”>#FFFFFF</color>
<color name=”navigationBarColor”>#000000</color>
<color name=”colorAccent”>#c8e8ff</color>
</resources>
ما نام تم متریال دیزاین را MyMaterialTheme انتخاب کردهایم.
styles.xml
<resources>
<style name=”MyMaterialTheme” parent=”MyMaterialTheme.Base”>
</style>
<style name=”MyMaterialTheme.Base” parent=”Theme.AppCompat.Light.DarkActionBar”>
<item name=”windowNoTitle”>true</item>
<item name=”windowActionBar”>false</item>
<item name=”colorPrimary”>@color/colorPrimary</item>
<item name=”colorPrimaryDark”>@color/colorPrimaryDark</item>
<item name=”colorAccent”>@color/colorAccent</item>
</style>
</resources>
و مقادیر زیر را در آن قرار دهید.
styles.xml
<resources>
<style name=”MyMaterialTheme” parent=”MyMaterialTheme.Base”>
<item name=”android:windowContentTransitions”>true</item>
<item name=”android:windowAllowEnterTransitionOverlap”>true</item>
<item name=”android:windowAllowReturnTransitionOverlap”>true</item>
<item name=”android:windowSharedElementEnterTransition”>@android:transition/move</item>
<item name=”android:windowSharedElementExitTransition”>@android:transition/move</item>
</style>
</resources>
android:theme=”@style/MyMaterialTheme”
AndroidManifest.xml
<?xml version=”۱.۰″ encoding=”utf-8″?>
<manifest xmlns:android=”http://schemas.android.com/apk/res/android“
package=”info.androidhive.materialtabs” >
<application
android:allowBackup=”true”
android:icon=”@mipmap/ic_launcher”
android:label=”@string/app_name”
android:theme=”@style/MyMaterialTheme” >
<activity
android:name=”.activity.MainActivity”
android:label=”@string/app_name” >
<intent-filter>
<action android:name=”android.intent.action.MAIN” />
<category android:name=”android.intent.category.LAUNCHER” />
</intent-filter>
</activity>
</application>
</manifest>
اپلیکیشن را اجرا کنید و رنگ notification bar را مشاهده کنید. اگر رنگ notification bar تغییر کرده باشد معنی آن این هست که قالب متریال دیزاین با موفقیت اعمالشده است.
دیدگاه بگذارید
اولین نفری باشید که دیدگاه میگذارد