xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
tools:context=".MainActivity">
android:id="@+id/cardView"
android:layout_width="match_parent"
android:layout_height="190dp"
android:layout_centerInParent="true"
app:cardCornerRadius="22dp"
app:cardUseCompatPadding="true"
app:cardElevation="4dp"
android:foreground="@drawable/purple_bg"
android:clickable="true" >
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="@drawable/silver_bg">
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_below="@+id/cardView"
android:gravity="center"
android:text="Changing Card Color on Click"
android:textStyle="bold|italic"
android:textColor="#2F8C46"
android:textSize="20sp" />
Step 5: Working with the MainActivity.java file
Go to the MainActivity.java file and refer to the following code. Below is the code for the MainActivity.java file.
Java
package com.anas.gfghover;
import androidx.appcompat.app.AppCompatActivity;
import android.os.Bundle;
public class MainActivity extends AppCompatActivity {
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
}
}
برچسب:
نویسنده: دانیال باقری