UI tips for pre and post Lollipop
5 min readDec 9, 2015
When designing for multiple API versions there are times where you need to create layouts or drawables that target different API versions. Here are some examples of UI that works on Lollipop but has a graceful fallback for pre-Lollipop.
Toolbar Dropshadow
MainActivity.java
public class MainActivity extends AppCompatActivity {
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar);
setSupportActionBar(toolbar);
}
}
values/styles.xml
<resources>
<!-- Base application theme. -->
<style name="AppTheme" parent="Theme.AppCompat.Light.NoActionBar">
<!-- Customize your theme here. -->
<item name="colorPrimary">@color/colorPrimary</item>
<item name="colorPrimaryDark">@color/colorPrimaryDark</item>
<item name="colorAccent">@color/colorAccent</item>
<item name="android:textColorPrimary">@android:color/white</item>
</style>
</resources>
Lollipop (API v21+)
layout-v21/activity_main.xml
<?xml version="1.0" encoding="utf-8"?>
<FrameLayout…