I tried to make my Android app in Kotlin with Holo theme My code: activity_main.xml:
<RelativeLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:padding="16dp">
<TextView
android:id="@+id/label"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Enter your name:"
android:textSize="18sp"
android:layout_alignParentTop="true"
android:layout_centerHorizontal="true"
android:textColor="@android:color/black"/>
<EditText
android:id="@+id/nameEditText"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:hint="Name"
android:layout_below="@id/label"
android:layout_marginTop="16dp"
android:layout_centerHorizontal="true"/>
<Button
android:id="@+id/loginButton"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Login"
android:layout_below="@id/nameEditText"
android:layout_marginTop="16dp"
android:layout_centerHorizontal="true"/>
<TextView
android:id="@+id/forgotPasswordTextView"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Forgot password?"
android:textColor="@android:color/holo_blue_light"
android:layout_below="@id/loginButton"
android:layout_marginTop="16dp"
android:layout_centerHorizontal="true"/>
</RelativeLayout>
MainActivity.kt:
package resichat.messenger
import android.os.Bundle
import android.widget.Button
import android.widget.EditText
import android.widget.TextView
import android.widget.Toast
import androidx.appcompat.app.AppCompatActivity
class MainActivity : AppCompatActivity() {
override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
setContentView(R.layout.activity_main)
val nameEditText: EditText = findViewById(R.id.nameEditText)
val loginButton: Button = findViewById(R.id.loginButton)
val forgotPasswordTextView: TextView = findViewById(R.id.forgotPasswordTextView)
loginButton.setOnClickListener {
val name = nameEditText.text.toString()
if (name.isEmpty()) {
Toast.makeText(this, "Please enter your name", Toast.LENGTH_SHORT).show()
} else {
// Perform login action
Toast.makeText(this, "Welcome, $name", Toast.LENGTH_SHORT).show()
}
}
forgotPasswordTextView.setOnClickListener {
// Handle forgot password action
Toast.makeText(this, "Forgot password clicked", Toast.LENGTH_SHORT).show()
}
}
}
AndroidManifest.xml:
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools">
<application
android:allowBackup="true"
android:icon="@mipmap/ic_launcher"
android:label="@string/app_name"
android:roundIcon="@mipmap/ic_launcher_round"
android:supportsRtl="true"
android:theme="@android:style/Theme.Holo.Light">
<activity
android:name=".MainActivity"
android:exported="true" > <!-- или false, в зависимости от твоих нужд -->
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
</application>
</manifest>
When building, an error occurs:
Manifest merger failed : uses-sdk:minSdkVersion 16 cannot be smaller than version 19 declared in library [com.google.android.material:material:1.12.0] C:\Users\antidote\.gradle\caches\8.13\transforms\df0ae31f5849b8ddc2231abbdf851cf6\transformed\material-1.12.0\AndroidManifest.xml as the library might be using APIs not available in 16
Suggestion: use a compatible library with a minSdk of at most 16,
or increase this project's minSdk version to at least 19,
or use tools:overrideLibrary="com.google.android.material" to force usage (may lead to runtime failures)
although the Preview shows that the theme is loading priview How can I solve the problem without updating the theme to Material?
If I update min API in Gradle, then yes, the problem will go away, but I need support for older devices (I really need Android 4.0 support)