Style. The XML file:
<style name="AppTheme" parent "=" Theme. AppCompat. Light. NoActionBar "& gt;
</style>
MainActivity. Java file:
Package com. Example. Materialtest;
import androidx.appcompat.app.AppCompatActivity;
import android.os.Bundle;
The import androidx. Appcompat. Widget. The Toolbar;
Public class MainActivity extends AppCompatActivity {
@ Override
Protected void onCreate (Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
The Toolbar Toolbar=(Toolbar) the findViewById (R.i which oolbar);
SetSupportActionBar (toolbar);
}
}
Build. Gradle dependencies in the file:
Dependencies {
Implementation fileTree (dir: 'libs', include: [' *. Jar'])
Implementation 'androidx. Appcompat: appcompat: 1.0.2'
Implementation 'androidx. Constraintlayout: constraintlayout: 1.1.3'
TestImplementation 'junit: junit: 4.12'
AndroidTestImplementation 'androidx. Test: runner: 1.2.0'
AndroidTestImplementation 'androidx. Test. Espresso: espresso - core: 3.2.0'
Implementation 'com. Android. Support: appcompat - v7:29.0.0'
}
CodePudding user response:
Layout is given and see itCodePudding user response:
The implementation of 'com. Android. Support: appcompat - v7:29.0.0' to keep implementation 'androidx. Appcompat: appcompat: 1.0.2' is okCodePudding user response:
Excuse me, have you solved this problem, I also met this kind of situation,CodePudding user response: