Aim: Android Resources: (Color, Theme, String, Drawable).
Colors.xml
<resources>
<color name="purple_200">#FFBB86FC</color>
<color name="purple_500">#FF6200EE</color>
<color name="purple_700">#FF3700B3</color>
<color name="teal_200">#FF03DAC5</color>
<color name="teal_700">#FF018786</color>
<color name="black">#FF000000</color>
<color name="white">#FFFFFFFF</color>
</resources>
To apply color to Textview :
Using code
<TextView
android:layout_width="wrap_content" android:layout_height="wrap_content" android:background="@color/black" android:text="HelloWorld!"
android:textColor="#FEFEFE"
app:layout_constraintBottom_toBottomOf="parent" app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent" app:layout_constraintTop_toTopOf="parent" />
or using attributes window
Note that we can apply only those colors which are stored in Colors.xml file
Dimensions
Theme:
Style.xml
<resources>
<!-- Base application theme. -->
<style name="AppTheme" parent="Theme.AppCompat.Light.DarkActionBar">
<!-- Customize your theme here. -->
<item name="colorPrimaryDark">@color/colorPrimaryDark</item>
</style>
</resources>
String.xml:
<resources>
<string name="app_name">My Application</string>
Using code
<TextView android:layout_width="wrap_content" android:layout_height="wrap_content" android:text="@string/college"
app:layout_constraintBottom_toBottomOf="parent" android:textColor="@color/deeppink" app:layout_constraintEnd_toEndOf="parent" app:layout_constraintStart_toStartOf="parent" app:layout_constraintTop_toTopOf="parent" />
Output
Drawable:
1. Right click on drawable folder
1. Copy the image
if you want to create image drawable
Now
to apply image to background of activity -à select activity -à attributes -à backgroundà name of image
Comments
Post a Comment
If you have any doubts, Please let me know.