Please Help Me.
While changing the theme from light mode to dark mode. How do I change the button's theme from filledbutton to outlinedbutton?
I saw an app from play store. Here I noticed that the buttons theme is changing:
This is LIGHT MODE :
This is DARK MODE :
I want to change the buttons theme like this. Can anybody tell how to do that?
Any help would be appreciated
Thank you.
Use the materialButtonStyle attribute in your theme:
<style name="AppTheme" parent="Theme.MaterialComponents.*">
...
<item name="materialButtonStyle">#style/CustomButton</item>
</style>
Then in a light theme use Widget.MaterialComponents.Button as parent:
<style name="CustomButton" parent="#style/Widget.MaterialComponents.Button">
...
</style>
and in the values-night directory use the Widget.MaterialComponents.Button.OutlinedButton as parent:
<style name="CustomButton" parent="Widget.MaterialComponents.Button.OutlinedButton">
...
</style>
use " androidx.appcompat.widget.AppCompatButton "this instead of " Button" this it will automatically changes with the UI theme.
Please check Image here for better Understanding
Related
In my project I selected Theme.AppCompat.Light.NoActionBar as the base theme, but in the Android Studio layout editor preview, it is showing a white toolbar with the activity name like this screenshot
This the style declared in styles.xml
<style name="AppTheme.Base" parent="Theme.AppCompat.Light.NoActionBar">
<item name="colorPrimary">#color/primary</item>
<item name="colorPrimaryDark">#color/primary_dark</item>
<item name="colorAccent">#color/accent</item>
</style>
But in the emulator it is not showing the toolbar. Anyone know why it is showing like this or a way to fix this.
Don't know, it can be considered as answer. But this is how i fixed it. It happened after i updated sdk to v22. Change the version of device shown in preview from 22 to 21.
If I set the background color, the margins between the buttons using this style are much smaller than without it. Why? How do I fix this?
<style name="RemoteButton">
<!-- Leaving this in makes the buttons very close together, without it, the margins increase -->
<item name="android:background">#d6d7d7</item>
<item name="android:layout_width">0dp</item>
<item name="android:layout_height">match_parent</item>
<item name="android:textColor">#556699</item>
<item name="android:textSize">20dp</item>
<item name="android:layout_margin">3dp</item>
</style>
The default button style is not a color, it's a drawable resource (#android:drawable/btn_default) with internal padding/margins. There is some information on it here but not much that's relevant. I would look further into android styles and how they work.
As to how to fix it, I would look here.
Add a view with other color between buttons.
Or choice a picture that not fill button as a background.
The reason that makes buttons very close is that you use a color as a background,then,the color will fill your button widget if without margin.
I have two issues:
1 When i use to develop android application on eclipse i remarked that in layout editor there is the ability to change the theme,but i can't to figure out where these modifications are saved.
2 In AndroidManifest.xml whene i apply a light theme for an activity still it's black
Style file contains:
<style name="NoActionBar" parent="android:Theme.Holo.Light.NoActionBar"></style>
Manifest file contains:
<activity
android:name="com.example.myapp.MainActivity"
android:theme="#style/NoActionBar"/>
I am having trouble to figure out these issues.
Thank you in advance
I would like the current menu item to stay highlighted when a user is in that section. I set up styles for .current-menu-item. For some reason some styles work and some don't. I used all of these for testing purposes:
.current-menu-item {
color:#F90;
border-bottom:2px solid #fco;
text-decoration:line-through;
background:#000;
}
Background and Text-Decorationare the only styles that work. Any clues why the others do not? I really only want the text color to stay orange (highlighted #f90).
Thanks in advance for any help :)
sandra :)
Your color rule is likely being overridden by a more specific rule. You can investigate this further, using 'Inspect Element' in google chrome, and looking at the styles in the inspector.
Can any one tell me how to disable "save as" and "print" option of browser menu bar?
if I go through File->Save As or Print, the document gets printed and saved.
I want to prevent this.
Can any one help me out in this issue?
Thanks in advance
<style type="text/css">
#media print{
body {display:none;}
}
</style>
The above code can be used to disable the user from printing the webpage.I have tested this code, its working fine for me in IE8, Chrome and Firefox.