I'm looking over design support library examples in the "Cheesesquare" demo of newer components I want to use. On my OnePlus One, the Toolbar is barely off-screen.
I think CheeseDetailActivity.java, activity_detail.xml, and maybe styles.xml are pertinent here but I can't seem to make changes that correct the misalignment.
Marked fixed for future release in AOSP Issue Tracker #175069
Related
So i'm updating my apps to fully support Monet and Material You guidelines, and the official site mentions a new design for the switches. I used it, and that's the result:
I have a preference screen using Androidx preferences library, latest version available at the time of writing, and the only way i found to theme the switches (except the manual theming, which makes no sense) is to use this line in the app's theme:
<item name="switchStyle">#style/Widget.Material3.CompoundButton.MaterialSwitch</item>
And using SwitchPreferenceCompat (it doesn't work in the regular SwitchPreference) this is what i get:
Regardless of the width (which is different, but can be changed) the disabled state is completely different and doesn't match the rest of the app. Why? and most importantly, why do they suggest to use a library which:
Doesn't support Material You out of the box
Doesn't support any new Material3 component
It's hard to properly customize in general
?
I don't want to be too critical, but this is out of my understanding.
EDIT: at the moment, i'm using switchCompat everywhere, to make the app uniform. Looking at the system apps, i can find 4 different type of switches: a custom switch similar to the second screenshot, the old one and the two types in this question. That's hella confusing.
I understand Google stance on this, they don't want to make androidx.* packages dependent to Material library itself, maybe they should provide a separate preference package but this time with fully Material widgets.
In order to have the brand new MaterialSwitch of Material 1.7.0 with preference, I've overridden its widgetLayout with a custom layout by android:widgetLayout="#layout/preference_material_switch" (in fact I applied that programmatically like .widgetLayoutResource = R.layout.preference_material_switch) and put the following on preference_material_switch.xml layout file,
<?xml version="1.0" encoding="utf-8"?>
<!-- Derived from https://github.com/androidx/androidx/blob/8cb282cc/preference/preference/res/layout/preference_widget_switch_compat.xml -->
<com.google.android.material.materialswitch.MaterialSwitch xmlns:android="http://schemas.android.com/apk/res/android"
android:id="#+id/switchWidget"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:background="#null"
android:clickable="false"
android:focusable="false" />
And here is the result,
The same problem, After seeing these replies, I'm thinking to build the settings fragment without androidx.preference.
MKevin3 said:
I hate the provided Android preferences setup and look. So many times they changed the rules and broke what I had.
Not that this helps you probably but I just did my own to avoid all the headaches and I am in full control of the look. If push comes to hove you might consider doing this as well instead of fighting the "Android Way".
sc00ty said:
I gave up trying to use their widgets and fragments. It was so much less of a headache to spend a little time making my own compound widgets for each setting type.
I used Theme.MaterialComponents.Light.NoActionBar theme and it seems to be affecting constrained layout which is some of elements(such as buttons) can not see in the "Design and Blueprint". But they are appearing properly when the app is running.
I tried the following steps but no use.
1) Try to clean the project
2) Try to invalidate and restart Android Studio
3) Try Rebuilding the project
I tried adding Base key word but it seems to be wrong.
<style name="AppTheme" parent="Base.Theme.MaterialComponents.Light.NoActionBar">
I'm currently using the latest dependency which is 'com.google.android.material:material:1.1.0-alpha07'
It seems to be ok with early dependency such as 'com.google.android.material:material:1.0.0' but I'm wondering why it is not working with the latest releases.
I could use different theme which do not have material components and overcome this problem as well, but it is not what I'm expecting.
Your answers and comments are highly appreciated.
This issue is directly related to the version of material design. I used the latest version of android studio with latest version material design in the constraint layout. The same issue happened when I dropped a button from the palette to layout, it made the layout vanish and I changed the theme to the default, it also worked fine. But as u said, I should use material design. When I used latest material design version( com.google.android.material:material:1.7.0), it didn't work but when I used com.google.android.material:material:1.5.0, it worked fine. That's why u can change the version to find the one which is compatible and not buggy.
Has anyone managed to bring the items in a V4 PagerTabStrip together, more like Google Play Store?
http://developer.android.com/reference/android/support/v4/view/PagerTabStrip.html
This is what I want:
This is what i get (the space between segments):
These images are not mine but its just to explain what I mean.
Additionally the underline for the Strip, is it possible to have a different color then the selected item underline (v4).
Thanks
Edit: For all those asking if I ever found a solution, I never did. Sorry :-(
I'm also searching the answers to this questions and it seems not exist the api to do such thing in android-support-v4. But as an alternative, we can try this https://github.com/xiaopansky/PagerSlidingTabStrip . Not a perfect but time-saving solution.
So it's been a while on this topic but I believe there are people still searching for this answer so I wanted to put here what I've found.
https://developer.android.com/samples/SlidingTabsBasic/src/com.example.android.common/view/SlidingTabStrip.html
On Android's developer website, they have sample code on how to accomplish it yourself. I personally haven't tested it yet so not sure if it supports that exact look and feel or whether it supports customization but at least the code is there for yourself and you can play around with it. I'd really wish that v4 PagerTitleStrip and PagerTabStrip supported the above features by default.
The default PagerTitleStrip has only 3 textviews initialized. So if You wish to remove spacing create a custom PagerTitleStrip class and add more textviews so that space is reduced.
The last few days I've been doing great stuff in development, but I've seem to have hit a wall on something probably stupid simple. It's annoying. I was hoping I could get some help.
What I'm trying to do
I'm trying to create the awesome transparent ActionBar animation effect from Google Music (as described by Cyril Mottier here)
The problem
I can't even get the actionbar to go into overlay / transparent mode.
My set-up
I've got a library-oriented set-up in Eclipse. I've got a library project (let's call it master) that contains all the actual code and activities. Then I've got a project, that just plugs into the master library (let's call it slave). Lastly there's some open source support libraries that master uses (among others is ActionBarSherlock).
The activity I'm trying to apply this effect to is in the master library. It is declared in slave's manifest as com.example.master.DetailActivity, and that works like a charm.
Also: The theme for the activity may come from several places. Either it's set by slave's manifest, or by master at runtime. Themes may come from the master OR the slave project.
What I've tried
Feels like everything. I've started out by creating a custom theme based on Cyril's article. I made sure that for every item I've had a version with and without the android: prefix as per Jake Wharton's instructions.
I've also tried setting it at runtime using requestWindowFeature(Window.FEATURE_ACTION_BAR_OVERLAY);
What I've got
Nothing. The theme applied succesfully (I can see the actionbar's colors change appropriately), but it NEVER goes into overlay mode, nor does it become transparent.
Help would be greatly appreciated, and would probably be helpful to other's trying this effect.
EDIT:
Here are my themes and styles. Codes are kinda messy because I've been experimenting with them to see where I was going wrong. AppTheme and Theme.TranslucentActionBar.ActionBar.Overlay both won't work.
/res/values/
styles.xml
themes.xml
/res/values-v11/
styles.xml
themes.xml
I'm testing on a Nexus 4 with 4.2.2 installed as well as a 2.3.3 emulator.
OK, so apparently, with my set-up, you can't do it using themes.
I ended it up doing it, globally like this.
setTheme(theme.whatever);
requestWindowFeature(Window.FEATURE_ACTION_BAR_OVERLAY);
super.onCreate(savedInstanceState);
setContentView(R.layout.content);
getSupportActionBar().setBackgroundDrawable(getResources().getDrawable(R.drawable.color)); // This is #212121 solid color for the dark action bar.
The lines are spread out over my code, but this is the gist of it. The order is important.
I also found out that sliding menu seemed to be blocking the overlay mode. I had to remove the instance for it to work. I'm still looking for a way to enable both overlay mode and the sliding menu.
There are lots of way to style ListViews to give them elegant look, but all of them involve modyfying the adapter or writing additional code.
With the release of Android 4.0, unfortunetely things have to change. Google polished their Holo theme and gave it new look. All of the developers are now encouraged to use it, in order to make all apps look the same.
And here's the problem. Google rolled out 4.0, but there are still people using older Android versions. We can't just leave our previous custom application themes and use Holo, because it will ruin visual experience for users with older devices. And we can't force 4.0 users just to use Holo, because let's be honest - it's still not perfect.
The goal is to use builtin themes system and prepare some alternatives for Holo, which will look great on all devices. Then we can just switch between Holo and our themes with just setTheme() and no additional problems. Unfortunetely it's not that simple. We are limited to the capabilities of existing theme system and some things are just hard to do. And here comes my question.
Taking everything I've mentioned into consideration, how can we control ListView look? I'm not able to figure out, how to:
create list with rounded corners and make sure the selector background doesn't ruin it when selecting first/last element
create rounded corners not for the list but sections separated by headers, something like here:
The solution should affect ListViews created by PreferenceActivity without any additional lines of code. Everything should be contained in the theme:
<theme name="SampleTheme" parent="android:Theme">
...
</theme>
I kindly ask not to post solutions that do not use styles & themes. They can be easily found in another questions, here on Stack Overflow.
Thanks in advance.
I can see two ways to solve this.
One is simply to use a theme for your listviews specifying the background, which in turn is a 9 patch with rounded corners or an xml shape you specify (with rounded corners as well). This will have the side-effect of the listview row selector appearing 'over' the background you specified, therefore kind of spoiling the effect. It is quite straightforward to implement though.
The second option is to simply always add headers and footers to your listviews, which have backgrounds that are selectors with rounded corners on top (and bottom). You can specify styles for these as well if you really want to.
Sorry for this last comment, but I had to say it. Please don't try to make your app look like an iPhone app :)