How can I put the circular imageView on top of the cardView like in this design? I want to use XML to do this.
you can achieve something similar that you can extended or enhance using the blow code
XML
<?xml version="1.0" encoding="utf-8"?>
<androidx.constraintlayout.widget.ConstraintLayout
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:background="#2D2D2D"
android:layout_height="match_parent"
tools:context=".MainActivity">
<androidx.constraintlayout.widget.Guideline
android:orientation="horizontal"
android:id="#+id/guideline"
android:layout_width="match_parent"
android:layout_height="wrap_content"
app:layout_constraintGuide_percent=".3"
/>
<com.google.android.material.card.MaterialCardView
style="#style/CardViewStyle"
android:id="#+id/cardview"
android:layout_width="0dp"
android:layout_height="0dp"
android:layout_marginTop="48dp"
app:cardBackgroundColor="#F3C623"
android:layout_marginBottom="16dp"
app:layout_constraintTop_toBottomOf="#id/guideline"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintWidth_percent="0.8" />
<com.google.android.material.imageview.ShapeableImageView
app:shapeAppearanceOverlay="#style/circleImageView"
android:id="#+id/image"
android:src="#mipmap/ic_launcher"
android:padding="1dp"
android:elevation="5dp"
android:layout_marginEnd="12dp"
android:layout_width="220dp"
android:layout_height="220dp"
app:layout_constraintTop_toTopOf="#id/guideline"
app:layout_constraintBottom_toTopOf="#id/guideline"
app:layout_constraintEnd_toEndOf="#id/cardview"
/>
</androidx.constraintlayout.widget.ConstraintLayout>
styles.xml
your Apptheme Should extend MaterialComponentstheme
<style name="AppTheme" parent="Theme.MaterialComponents.Light.DarkActionBar">
<!-- Customize your theme here. -->
<item name="colorPrimary">#color/colorPrimary</item>
<item name="colorPrimaryDark">#color/colorPrimaryDark</item>
<item name="colorAccent">#color/colorAccent</item>
</style>
<style name="CardViewStyle" parent="#style/Widget.MaterialComponents.CardView">
<item name="shapeAppearanceOverlay">#style/MaterialCardViewRounded</item>
</style>
<style name="MaterialCardViewRounded" parent="">
<item name="cornerFamily">rounded</item>
<item name="cornerSizeTopRight">48dp</item>
<item name="cornerSizeTopLeft">0dp</item>
<item name="cornerSizeBottomRight">48dp</item>
<item name="cornerSizeBottomLeft">0dp</item>
</style>
<style name="circleImageView" parent="">
<item name="cornerFamily">rounded</item>
<item name="cornerSize">50%</item>
</style>
buid.gradle
add the matrial comonent dependance
implementation "com.google.android.material:material:1.2.1"
Related
I have the following layout:
<?xml version="1.0" encoding="utf-8"?>
<androidx.constraintlayout.widget.ConstraintLayout
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:layout_width="match_parent"
android:layout_height="match_parent">
<androidx.camera.view.PreviewView
android:id="#+id/viewFinder"
android:layout_width="match_parent"
android:layout_height="match_parent" />
<com.google.android.material.button.MaterialButton
android:id="#+id/btn_image_select"
android:layout_width="50dp"
android:layout_height="50dp"
android:layout_margin="20dp"
app:icon="#drawable/baseline_photo_24"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintStart_toStartOf="parent"
style="#style/MaterialIconButtonCircledDarkTransparentStyle"
/>
<com.google.android.material.button.MaterialButton
android:id="#+id/btn_image_capture"
android:layout_width="75dp"
android:layout_height="75dp"
android:layout_margin="20dp"
app:strokeWidth="2dp"
app:strokeColor="#color/white"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintBottom_toBottomOf="parent"
style="#style/MaterialIconButtonCircledLightTransparentStyle"
/>
</androidx.constraintlayout.widget.ConstraintLayout>
With the following style:
<style name="MaterialIconButtonCircledDarkTransparentStyle">
<item name="android:insetLeft">0dp</item>
<item name="android:insetTop">0dp</item>
<item name="android:insetRight">0dp</item>
<item name="android:insetBottom">0dp</item>
<item name="iconPadding">0dp</item>
<item name="iconGravity">textStart</item>
<item name="background">#color/BlackTransparent</item>
<item name="shapeAppearanceOverlay">#style/ShapeAppearanceOverlayMaterialIconButtonCircular</item>
</style>
<style name="MaterialIconButtonCircledLightTransparentStyle" parent="MaterialIconButtonCircledDarkTransparentStyle">
<item name="android:backgroundTint">#color/LightGrayTransparent</item>
</style>
<style name="ShapeAppearanceOverlayMaterialIconButtonCircular" parent="">
<item name="cornerFamily">rounded</item>
<item name="cornerSize">50%</item>
</style>
<color name="LightGrayTransparent">#80C0C0C0</color>
<color name="BlackTransparent">#6A000000</color>
Which looks like this:
As you can see there is a random pentagon shaped style which is visible when I have a transparent backgroundTint.
Any idea how I can hide the pentagon shaped form?
I tried setting the ripple color to null and other options, but none of them worked unfourtantly.
I have integrated some tabs in my app, but the tabs keep the text color stays white even thought I have set some shades of gray in its colors:
tabs.SetTabTextColors(Color.ParseColor("#bdbdbd"), Color.ParseColor("#212121"));
This is how it looks:
This is my XML:
<?xml version="1.0" encoding="UTF-8" ?>
<ScrollView
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:fillViewport="true">
<LinearLayout
android:theme="#style/AppTheme"
android:orientation="vertical"
android:layout_width="match_parent"
android:layout_height="wrap_content">
<com.jsibbold.zoomage.ZoomageView
android:adjustViewBounds="true"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:id="#+id/imgRuin"
app:zoomage_restrictBounds="false"
app:zoomage_animateOnReset="true"
app:zoomage_autoResetMode="UNDER"
app:zoomage_autoCenter="true"
app:zoomage_zoomable="true"
app:zoomage_translatable="true"
app:zoomage_minScale="0.6"
app:zoomage_maxScale="8" />
<TextView
android:layout_marginTop="5dp"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:gravity="center_horizontal"
android:textStyle="italic"
android:textSize="12dp"
android:textColor="#4c8c4a"
android:id="#+id/lblImgDescription" />
<com.google.android.material.tabs.TabLayout
android:id="#+id/mTabOptions"
android:layout_width="match_parent"
android:layout_height="wrap_content">
<com.google.android.material.tabs.TabItem
android:id="#+id/tabOverview"
android:text="#string/tabOverview"
android:layout_width="match_parent"
android:layout_height="wrap_content" />
<com.google.android.material.tabs.TabItem
android:id="#+id/tabPreview"
android:text="#string/tabPreview"
android:layout_width="match_parent"
android:layout_height="wrap_content" />
<com.google.android.material.tabs.TabItem
android:id="#+id/tabDetails"
android:text="#string/tabDetails"
android:layout_width="match_parent"
android:layout_height="wrap_content" />
<com.google.android.material.tabs.TabItem
android:id="#+id/tabLocation"
android:text="#string/tabLocation"
android:layout_width="match_parent"
android:layout_height="wrap_content" />
</com.google.android.material.tabs.TabLayout>
<androidx.viewpager2.widget.ViewPager2
android:id="#+id/viewpager"
android:layout_width="match_parent"
android:layout_height="match_parent" />
</LinearLayout>
</ScrollView>
This is my style:
<?xml version="1.0" encoding="UTF-8"?>
<resources>
<style name="AppTheme.Launcher" parent="android:Theme.Material.Light">
<item name="android:windowBackground">#drawable/launch_screen</item>
<item name="android:windowActionBar">false</item>
<item name="android:windowNoTitle">true</item>
</style>
<!-- Base application theme. -->
<style name="AppTheme" parent="Theme.AppCompat.Light.DarkActionBar">
<!-- Customize your theme here. -->
<item name="colorPrimary">#color/colorPrimary</item>
<item name="colorPrimaryDark">#color/colorPrimaryDark</item>
<item name="colorAccent">#color/colorAccent</item>
</style>
<style name="AppTheme.NoActionBar">
<item name="windowActionBar">false</item>
<item name="windowNoTitle">true</item>
</style>
<!-- ToolBar -->
<style name="ToolBarStyle" parent="Theme.AppCompat">
<item name="android:textColorPrimary">#android:color/white</item>
<item name="android:textColorSecondary">#android:color/white</item>
<item name="actionMenuTextColor">#android:color/white</item>
<item name="android:itemTextAppearance">#android:color/white</item>
</style>
<style name="AppTheme.AppBarOverlay" parent="ThemeOverlay.AppCompat.Dark.ActionBar" />
<style name="AppTheme.PopupOverlay" parent="ThemeOverlay.AppCompat.Light" />
<style name="progressBarStyle" parent="#style/Widget.AppCompat.ProgressBar.Horizontal">
<item name="android:indeterminateDrawable">#drawable/progress_bar_drawable</item>
</style>
</resources>
These are the colors:
<?xml version="1.0" encoding="utf-8"?>
<resources>
<color name="colorPrimary">#1b5e20</color>
<color name="colorPrimaryDark">#003300</color>
<color name="colorAccent">#4c8c4a</color>
</resources>
Any idea why they are always white?
It seems the text was not printed:
public class TabConfigurationStrategy : Java.Lang.Object, TabLayoutMediator.ITabConfigurationStrategy
{
public void OnConfigureTab(TabLayout.Tab p0, int p1)
{
switch (p1)
{
case 0:
p0.SetText(Resource.String.tabOverview);
break;
case 1:
p0.SetText(Resource.String.tabPreview);
break;
case 2:
p0.SetText(Resource.String.tabDetails);
break;
case 3:
p0.SetText(Resource.String.tabLocation);
break;
}
}
}
This is what I had to add.
Try to put both attributes into your TabLayout:
app:tabSelectedTextColor="#f01654"
app:tabTextColor="#1652f0"
Your final code would look like this:
<com.google.android.material.tabs.TabLayout
android:id="#+id/tab_layout"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_alignParentBottom="true"
android:layout_alignParentStart="true"
android:layout_gravity="bottom"
android:background="#color/button_background"
android:fillViewport="true"
app:tabBackground="#drawable/fixed_bottom_button"
app:tabIndicatorColor="#color/color_primary_text"
app:tabMode="fixed"
app:tabSelectedTextColor="#f01654"
app:tabTextColor="#1652f0" />
I'm pretty new to Android, and trying to define a style for my layout.
My layout is as follows:
<?xml version="1.0" encoding="utf-8"?>
<com.google.android.material.card.MaterialCardView
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:layout_width="150dp"
android:layout_height="150dp"
android:layout_margin="10dp"
app:cardCornerRadius="20dp"
app:cardPreventCornerOverlap="true">
<ImageView
android:id="#+id/image"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:adjustViewBounds="true"
android:scaleType="fitXY"
android:src="#drawable/background_test"/>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_gravity="bottom"
android:background="#color/transparent_white"
android:orientation="vertical">
<TextView
android:id="#+id/title"
style="#style/TitleScrollable"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:gravity="center" />
<TextView
android:id="#+id/subtitle"
style="#style/SubtitleScrollable"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:gravity="center" />
</LinearLayout>
</com.google.android.material.card.MaterialCardView>
In my style.xml:
<style name="Title" parent="#style/TextAppearance.MaterialComponents.Headline5">
<item name="android:text">Long Long Title</item>
<item name="android:textStyle">bold</item>
<item name="android:textSize">22sp</item>
<item name="android:textColor">#color/primaryDark</item>
</style>
<style name="TitleScrollable" parent="Title">
<item name="singleLine">true</item>
<item name="maxLines">1</item>
<item name="android:ellipsize">marquee</item>
<item name="android:marqueeRepeatLimit">marquee_forever</item>
<item name="android:scrollHorizontally">true</item>
<item name="android:focusable">true</item>
<item name="android:focusableInTouchMode">true</item>
</style>
But my title is still wrapping to next lines.
When i use this style elsewhere it works fine.
When adding maxLines=1 in the layout it works fine.
I am trying to style the material buttons using the new styles offered by the implementation 'com.google.android.material:material:1.0.0'
library. The issue is that the buttons are not styling properly. For example, I have 2 different activities using the exact same theme, with the exact same code for the button but on refuses to use the right style, on the Android preview screen it looks right but in the actual app its not.
Also, I am manually overriding the style of a group of buttons by setting style="myButtonStyleWhatever" but that just gets ignored as well. This is getting very frustrating so I would love if someone could help.
Styles-v11
<?xml version="1.0" encoding="utf-8"?>
<resources>
<style name="MyMaterialTheme.Base" parent="Theme.MaterialComponents.Light.NoActionBar">
<item name="windowNoTitle">true</item>
<item name="windowActionBar">false</item>
<item name="colorPrimary">#color/colorPrimary</item>
<item name="colorPrimaryDark">#color/colorPrimaryDark</item>
<item name="colorAccent">#color/colorPrimaryDark</item>
</style>
<style name="ToolBarStyle" parent="Theme.AppCompat">
<item name="colorPrimary">#364c70</item>
<item name="actionMenuTextColor">#android:color/white</item>
</style>
<style name="WhiteButtons" parent="Widget.MaterialComponents.Button">
<item name="android:background">#ffff</item>
<item name="android:textColor">#000</item>
</style>
</resources>
Styles-v21
<?xml version="1.0" encoding="utf-8"?>
<resources>
<style name="MyMaterialTheme" parent="Theme.MaterialComponents.Light.NoActionBar">
<item name="android:windowContentTransitions">true</item>
<item name="android:windowAllowEnterTransitionOverlap">true</item>
<item name="android:windowAllowReturnTransitionOverlap">true</item>
<item name="android:windowSharedElementEnterTransition">#android:transition/move</item>
<item name="android:windowSharedElementExitTransition">#android:transition/move</item>
</style>
<style name="MyMaterialTheme.Base" parent="Theme.MaterialComponents.Light.NoActionBar">
<item name="windowNoTitle">true</item>
<item name="windowActionBar">false</item>
<item name="colorPrimary">#color/colorPrimary</item>
<item name="colorPrimaryDark">#color/colorPrimaryDark</item>
<item name="colorAccent">#color/colorPrimaryDark</item>
</style>
</resources>
Styles
<resources>
<style name="MyMaterialTheme.Base" parent="Theme.MaterialComponents.Light.NoActionBar">
<item name="windowNoTitle">true</item>
<item name="windowActionBar">false</item>
<item name="colorPrimary">#color/colorPrimary</item>
<item name="colorPrimaryDark">#color/colorPrimaryDark</item>
<item name="colorAccent">#color/colorPrimaryDark</item>
</style>
<style name="ToolBarStyle" parent="Theme.AppCompat">
<item name="colorPrimary">#364c70</item>
<item name="actionMenuTextColor">#android:color/white</item>
</style>
<style name="WhiteButtons" parent="Widget.MaterialComponents.Button">
<item name="android:background">#ffff</item>
<item name="android:textColor">#000</item>
</style>
</resources>
Code used for the button
<com.google.android.material.button.MaterialButton
android:id="#+id/get_suggestions"
style="#style/Widget.MaterialComponents.Button.OutlinedButton"
android:layout_width="#dimen/_65sdp"
android:layout_height="wrap_content"
android:layout_marginStart="163dp"
android:layout_marginTop="83dp"
android:layout_marginEnd="163dp"
android:layout_marginBottom="219dp"
android:text="SEARCH"
android:textSize="#dimen/_9sdp"
app:cornerRadius="100dp" />
Not meant to look like that
<!-- MAIN CONTENT -->
<com.sothree.slidinguppanel.SlidingUpPanelLayout
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:sothree="http://schemas.android.com/apk/res-auto"
xmlns:mapbox="http://schemas.android.com/apk/res-auto"
xmlns:app="http://schemas.android.com/xmlns:app="
xmlns:tools="http://schemas.android.com/tools"
android:id="#+id/sliding_layout"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:gravity="bottom"
android:windowSoftInputMode="adjustNothing"
sothree:umanoPanelHeight="68dp"
sothree:umanoShadowHeight="4dp"
sothree:umanoParallaxOffset="100dp"
sothree:umanoDragView="#+id/dragger"
sothree:umanoOverlay="true"
sothree:umanoScrollableView="#+id/dragView">
<androidx.drawerlayout.widget.DrawerLayout
android:layout_width="match_parent"
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:id="#+id/drawer"
android:focusableInTouchMode="true"
android:layout_height="match_parent">
<FrameLayout
android:layout_width="match_parent"
android:layout_height="match_parent">
<androidx.constraintlayout.widget.ConstraintLayout
android:layout_width="match_parent"
android:id="#+id/parent"
android:layout_height="match_parent">
<com.mancj.materialsearchbar.MaterialSearchBar
android:id="#+id/search"
android:layout_width="#dimen/_233sdp"
android:layout_height="#dimen/_58sdp"
android:layout_marginStart="8dp"
android:layout_marginTop="5dp"
android:elevation="100dp"
android:imeOptions="actionSearch"
sothree:layout_constraintStart_toStartOf="parent"
sothree:layout_constraintTop_toTopOf="parent"
tools:ignore="UnusedAttribute" />
<com.google.android.material.button.MaterialButton
style="#style/Widget.MaterialComponents.Button.OutlinedButton"
android:id="#+id/get_suggestions"
android:layout_width="#dimen/_65sdp"
android:layout_height="wrap_content"
android:layout_marginEnd="4dp"
android:layout_marginTop="10dp"
app:cornerRadius="100dp"
android:text="SEARCH"
android:textSize="#dimen/_9sdp"
sothree:layout_constraintEnd_toEndOf="parent"
sothree:layout_constraintTop_toTopOf="parent" />
<com.mapbox.mapboxsdk.maps.MapView
android:id="#+id/mapview"
android:layout_width="match_parent"
android:layout_height="match_parent"
mapbox:mapbox_cameraTargetLat="46.885"
mapbox:mapbox_cameraTargetLng="24.679"
mapbox:mapbox_cameraTilt="20"
mapbox:mapbox_cameraZoom="4"
mapbox:mapbox_styleUrl="mapbox://styles/sudafly/cjm89d4011nu02smk5a7e0d8h"
sothree:layout_constraintBottom_toBottomOf="parent"
sothree:layout_constraintEnd_toEndOf="parent"
sothree:layout_constraintStart_toStartOf="parent"
sothree:layout_constraintTop_toTopOf="parent">
</com.mapbox.mapboxsdk.maps.MapView>
</androidx.constraintlayout.widget.ConstraintLayout>
</FrameLayout>
<com.google.android.material.navigation.NavigationView
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:id="#+id/nav_menu"
android:layout_gravity="start"
app:headerLayout="#layout/nav_header"
app:menu="#menu/navigation_menu"
/>
</androidx.drawerlayout.widget.DrawerLayout>
<!-- SLIDING LAYOUT -->
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:id="#+id/dragView"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="#ffffff"
android:clickable="true"
android:focusable="false"
android:orientation="vertical">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="68dp"
android:background="#2a2e41"
android:id="#+id/dragger"
android:orientation="horizontal">
<TextView
android:id="#+id/name"
android:layout_width="0dp"
android:layout_height="match_parent"
android:layout_weight="1"
android:gravity="center_vertical"
android:paddingLeft="10dp"
android:text="#string/search_for_airports"
android:textColor="#d2d4e0"
android:textSize="20dp" />
</LinearLayout>
<androidx.constraintlayout.widget.ConstraintLayout
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:id="#+id/drag"
android:background="#eceff1">
<LinearLayout
android:id="#+id/Lin"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent">
<com.google.android.material.appbar.AppBarLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="#eceff1"
android:elevation="#dimen/_20sdp"
android:theme="#style/AppTheme.AppBarOverlay"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent">
<com.google.android.material.tabs.TabLayout
android:id="#+id/tab"
android:layout_width="match_parent"
android:layout_height="wrap_content">
</com.google.android.material.tabs.TabLayout>
<androidx.constraintlayout.widget.ConstraintLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:padding="0dp">
<include layout="#layout/charts_v2" />
<include layout="#layout/content_main" />
</androidx.constraintlayout.widget.ConstraintLayout>
</com.google.android.material.appbar.AppBarLayout>
</LinearLayout>
</androidx.constraintlayout.widget.ConstraintLayout>
</LinearLayout>
</com.sothree.slidinguppanel.SlidingUpPanelLayout>
The styles you've posted don't make a ton of sense.
You are showing ToolBarStyle and WhiteButtons styles but you're not using them anywhere.
You have MyMaterialTheme (as opposed to MyMaterialTheme.Base) in one of the files; I hope you aren't expecting this to be automatically inherited from by MyMaterialTheme.Base, since specifying a parent overrides the dot-notation inheritance.
All three files have the same contents for MyMaterialTheme.Base; why bother specifying it in three places?
Additionally, none of the styles you've posted seem like they would affect MaterialButton widgets (except for colorPrimary). So it's hard to know exactly where your problem lies.
All that said, the list of attributes supported by MaterialButton is available in the GitHub documentation. Notably, android:background is not supported by MaterialButton. From the JavaDoc:
Do not use the android:background attribute. MaterialButton manages its own background drawable, and setting a new background means MaterialButton can no longer guarantee that the new attributes it introduces will function properly. If the default background is changed, MaterialButton cannot guarantee well-defined behavior.
I suspect that what you're seeing is a combination of different colorPrimary definitions on the two screens and the fact that android:background is not supported.
If you want to manually override the button's background color, use the app:backgroundTint attribute on your <MaterialButton> tag. If you want to specify that in a <style> tag, it doesn't use a namespace:
<item name="backgroundTint">#color/your_background_color</item>
Hi i am trying to start activity with this layout, but it works only on android 5+, when i am running it on older versions it always crushes. What may cause this? Maybe i am using some restricted for android version<5 xml fields?
Styles
https://drive.google.com/open?id=0B-pbp_K-xNkEb0pQbzIzd0FYMU0
https://drive.google.com/open?id=0B-pbp_K-xNkEWlpuanl3ejhxd2c
Layout
<?xml version="1.0" encoding="utf-8"?>
<android.support.design.widget.CoordinatorLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:fitsSystemWindows="true">
<android.support.design.widget.AppBarLayout
android:id="#+id/appbar"
android:layout_width="match_parent"
android:layout_height="192dp"
android:fitsSystemWindows="true"
android:theme="#style/ThemeOverlay.AppCompat.Dark.ActionBar">
<android.support.design.widget.CollapsingToolbarLayout
android:id="#+id/collapsing_toolbar"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:fitsSystemWindows="true"
app:contentScrim="?attr/colorPrimary"
app:expandedTitleMarginEnd="64dp"
app:expandedTitleMarginStart="48dp"
app:layout_scrollFlags="scroll|exitUntilCollapsed|snap">
<ImageView
android:id="#+id/header"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="#drawable/sport"
android:fitsSystemWindows="true"
android:scaleType="centerCrop"
app:layout_collapseMode="parallax" />
<android.support.v7.widget.Toolbar
android:id="#+id/anim_toolbar"
android:layout_width="match_parent"
android:layout_height="?attr/actionBarSize"
app:layout_collapseMode="pin"
app:popupTheme="#style/ThemeOverlay.AppCompat.Light" />
</android.support.design.widget.CollapsingToolbarLayout>
</android.support.design.widget.AppBarLayout>
<android.support.v4.widget.NestedScrollView
android:id="#+id/scroll"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="#color/background"
android:clipToPadding="false"
app:layout_behavior="#string/appbar_scrolling_view_behavior">
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="#color/background"
android:orientation="vertical">
<LinearLayout
android:id="#+id/title_lay"
android:layout_width="match_parent"
android:layout_height="72dp"
android:background="#color/background"
android:gravity="center_vertical"
android:orientation="horizontal"
android:paddingLeft="30dp"
android:paddingRight="30dp">
<FrameLayout
android:layout_width="40dp"
android:layout_height="40dp"
android:layout_marginRight="16dp">
<ImageView
android:id="#+id/iv_icon"
android:layout_width="40dp"
android:layout_height="40dp" />
</FrameLayout>
<LinearLayout
android:layout_width="0dp"
android:layout_height="match_parent"
android:layout_weight="1"
android:gravity="center_vertical"
android:orientation="vertical">
<TextView
android:id="#+id/club_title"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:gravity="center_vertical"
android:textSize="16sp"
android:textColor="#color/second_text" />
<TextView
android:id="#+id/club_description"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:gravity="center_vertical"
android:textColor="#color/text_color" />
</LinearLayout>
</LinearLayout>
<LinearLayout
android:id="#+id/subscription_lay"
android:layout_width="match_parent"
android:layout_height="40dp"
android:layout_below="#id/title_lay"
android:layout_marginBottom="8dp"
android:background="#drawable/backgroundtoolbar"
android:clickable="true"
android:gravity="center_vertical"
android:orientation="horizontal">
<ImageView
android:layout_width="24dp"
android:layout_height="24dp" />
<TextView
android:id="#+id/subscription_txt"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="#string/str_subscribe_on"
android:textSize="16sp" />
</LinearLayout>
<android.support.v7.widget.CardView
android:id="#+id/address_card_view"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_margin="8dp"
android:background="#color/second_background"
android:layout_below="#id/subscription_lay"
app:cardCornerRadius="4dp"
>
<RelativeLayout
android:id="#+id/address_lay"
android:layout_width="match_parent"
android:layout_height="48dp"
android:background="#color/second_background"
android:gravity="center_vertical"
android:paddingLeft="16dp"
android:paddingRight="16dp">
<TextView
android:id="#+id/club_address"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text=""
android:textColor="#color/second_text" />
<ImageView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentRight="true"
android:src="#drawable/ic_maps_place" />
</RelativeLayout>
</android.support.v7.widget.CardView>
<android.support.v7.widget.CardView
android:id="#+id/schedule_card_view"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_margin="8dp"
android:background="#color/second_background"
android:layout_below="#id/address_card_view"
app:cardCornerRadius="4dp"
>
<RelativeLayout
android:id="#+id/schedule_lay"
android:layout_width="match_parent"
android:layout_height="64dp"
android:background="#color/second_background"
android:gravity="center_vertical"
android:paddingLeft="16dp"
android:paddingRight="16dp">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:gravity="center_vertical"
android:orientation="vertical">
<TextView
android:id="#+id/club_schedule"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="#string/schedule_title"
android:gravity="center_vertical"
android:textColor="#color/text_color" />
<TextView
android:id="#+id/schedule_value"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text=""
android:gravity="center_vertical"
android:textColor="#color/second_text" />
</LinearLayout>
<ImageView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentRight="true"
android:layout_centerVertical="true"
android:src="#drawable/ic_notification_event_note" />
</RelativeLayout>
</android.support.v7.widget.CardView>
<android.support.v7.widget.CardView
android:id="#+id/contact_card_view"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_margin="8dp"
android:background="#color/second_background"
android:layout_below="#id/schedule_card_view"
app:cardCornerRadius="4dp"
>
<RelativeLayout
android:id="#+id/contact_lay"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="#color/second_background"
android:gravity="center_vertical"
android:paddingLeft="16dp"
android:paddingRight="16dp">
<RelativeLayout
android:id="#+id/phone_lay"
android:layout_width="match_parent"
android:gravity="center_vertical"
android:layout_height="64dp">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:gravity="center_vertical"
android:orientation="vertical">
<TextView
android:id="#+id/phone_title"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text=""
android:gravity="center_vertical"
android:textColor="#color/text_color" />
<TextView
android:id="#+id/phone_value"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text=""
android:gravity="center_vertical"
android:textColor="#color/second_text" />
</LinearLayout>
<ImageView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentRight="true"
android:layout_centerVertical="true"
android:src="#drawable/ic_maps_local_phone" />
</RelativeLayout>
<RelativeLayout
android:id="#+id/web_lay"
android:layout_width="match_parent"
android:layout_height="64dp"
android:gravity="center_vertical"
android:layout_below="#id/phone_lay">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:gravity="center_vertical"
android:orientation="vertical">
<TextView
android:id="#+id/web_title"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:gravity="center_vertical"
android:text=""
android:textColor="#color/text_color" />
<TextView
android:id="#+id/web_value"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:gravity="center_vertical"
android:text=""
android:textColor="#color/second_text" />
</LinearLayout>
<ImageView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentRight="true"
android:layout_centerVertical="true"
android:src="#drawable/ic_action_language" />
</RelativeLayout>
<RelativeLayout
android:id="#+id/mail_lay"
android:layout_width="match_parent"
android:layout_height="64dp"
android:gravity="center_vertical"
android:background="#color/second_background"
android:layout_below="#id/web_lay">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:gravity="center_vertical"
android:orientation="vertical">
<TextView
android:id="#+id/mail_title"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text=""
android:gravity="center_vertical"
android:textColor="#color/text_color" />
<TextView
android:id="#+id/mail_value"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="12-3123-123-34"
android:gravity="center_vertical"
android:textColor="#color/second_text" />
</LinearLayout>
<ImageView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentRight="true"
android:layout_centerVertical="true"
android:src="#drawable/ic_content_send" />
</RelativeLayout>
<View
android:id="#+id/devider"
android:layout_width="match_parent"
android:layout_height="1dp"
android:layout_below="#id/mail_lay"
android:paddingLeft="-30dp"
android:paddingRight="-30dp"
android:background="#color/second_background" />
<RelativeLayout
android:id="#+id/other_lay"
android:layout_width="match_parent"
android:layout_height="48dp"
android:gravity="center_vertical"
android:layout_below="#id/devider">
<TextView
android:id="#+id/club_contacts"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="#string/detail"
android:layout_centerVertical="true"
android:textColor="#color/text_color" />
<ImageView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentRight="true"
android:layout_centerVertical="true"
android:src="#drawable/ic_hardware_keyboard_arrow_right" />
</RelativeLayout>
</RelativeLayout>
</android.support.v7.widget.CardView>
</RelativeLayout>
</android.support.v4.widget.NestedScrollView>
</android.support.design.widget.CoordinatorLayout>
Styles
<!-- Base application theme. -->
<style name="AppTheme" parent="Theme.AppCompat.Light.DarkActionBar">
<!-- Customize your theme here. -->
<item name="colorPrimary">#color/colorPrimary</item>
<item name="colorPrimaryDark">#color/colorPrimaryDark</item>
<item name="colorAccent">#color/colorAccent</item>
</style>
<style name="AppTheme.NoActionBar" >
<item name="windowActionBar">false</item>
<item name="windowNoTitle">true</item>
</style>
Errors:
android.view.InflateException: Binary XML file line #17: Error inflating class <unknown>
Caused by: android.view.InflateException: Binary XML file line #17: Error inflating class <unknown>
Caused by: java.lang.reflect.InvocationTargetException
Caused by: java.lang.IllegalArgumentException: You need to use a Theme.AppCompat theme (or descendant) with the design library.
Gradle
apply plugin: 'com.android.application'
android {
compileSdkVersion 24
buildToolsVersion "23.0.2"
enforceUniquePackageName = false
defaultConfig {
applicationId "com.mycrosswod.crossfit"
minSdkVersion 15
targetSdkVersion 23
versionCode 1
versionName "1.0"
multiDexEnabled true
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
}
dependencies {
compile fileTree(include: ['*.jar'], dir: 'libs')
testCompile 'junit:junit:4.12'
compile 'com.android.support:appcompat-v7:24+'
compile 'com.android.support:design:24.0.0'
compile 'com.android.support:recyclerview-v7:24.0.0'
compile 'com.android.support:percent:24.0.0'
compile 'com.google.firebase:firebase-core:9.6.1'
compile 'com.google.android.gms:play-services-maps:9.6.1'
compile 'com.google.code.gson:gson:1.7.2'
compile 'com.squareup.picasso:picasso:2.5.2'
compile 'com.squareup.okhttp3:okhttp:3.1.2'
compile 'com.facebook.android:facebook-android-sdk:4+'
compile 'com.vk:androidsdk:+'
compile 'com.google.apis:google-api-services-youtube:v3-rev163-1.21.0'
compile 'com.thefinestartist:ytpa:1.2.1'
compile 'com.github.clans:fab:1.6.3'
compile "com.google.firebase:firebase-messaging:9.0.0"
compile 'com.android.support:multidex:1.0.1'
compile group: 'org.apache.commons', name: 'commons-lang3', version: '3.0'
}
apply plugin: 'com.google.gms.google-services'
The issue about android doesn't know which theme to take. it is the conflict between pre-lollipop and post lollipop devices, So we need to explicitly convert into No action bar theme. Adding
compile 'com.android.support:appcompat-v7:24.2.0'
here my case is v24, choose your convenient version.To defining pre lollipop devices we change the style scheme in res/values/style.xml as follows:
<!-- Base application theme. -->
<style name="AppTheme.Base" parent="Theme.AppCompat.Light.NoActionBar">
</style>
<style name="AppTheme" parent="AppTheme.Base">
<!-- Customize your theme here. -->
<item name="colorPrimary">#color/colorPrimary</item>
<item name="colorPrimaryDark">#color/colorPrimaryDark</item>
<item name="colorAccent">#color/colorAccent</item>
</style>
AppTheme inherited from AppTheme.Base it inherited from Theme.AppCompat.Light.NoActionBar. So here we can mention our supported color schemes here for pre-lollipop devices.Thats it :)
Material design supported from lollipop devices. we can add more color schemes here.We already defined AppTheme in res/values/styles.xml.
Now inherit same AppTheme from res/values/values/styles.xml to res/values/values-v21/styles.xml. So Values-v21/styles.xml as follows:
<style name="AppTheme" parent="AppTheme.Base">
<!-- Customize your theme here. -->
<item name="android:colorPrimary">#color/colorPrimary</item>
<item name="android:colorPrimaryDark">#color/colorPrimaryDark</item>
<item name="android:colorAccent">#color/colorAccent</item>
<item name="android:textColorPrimary">#color/colorPrimary</item>
<item name="android:windowBackground">#color/colorAccent</item>
<item name="android:navigationBarColor">#color/colorPrimary</item>
</style>
Try this. :-)
Change the lines as corresponding files values/v-2x/styles.xml
<style name="Base.MyTheme" parent="Theme.AppCompat.Light.NoActionBar">
<item name="colorPrimary">#color/colorPrimary</item>
<item name="colorPrimaryDark">#color/colorPrimaryDark</item>
<item name="colorAccent">#color/colorAccent</item>
<item name="windowActionBar">false</item>
<item name="windowActionBarOverlay">true</item>`
<item name="windowNoTitle">true</item>
</style>
<style name="MyTheme" parent="Base.MyTheme">
<item name="android:windowDrawsSystemBarBackgrounds">true</item>
</style>
final styles in values/v-2x/styles.xml
<resources>
<style name="CrossfitTextView" parent="#android:style/Widget.TextView">
<item name="android:textColor">#color/text_color</item>
<item name="android:drawableBottom">#color/tomato</item>
</style>
<style name="CrossfitSecondTextView" parent="#android:style/Widget.TextView">
<item name="android:textColor">#color/text_color2</item>
</style>
<style name="CrossfitTitleTextView" parent="#android:style/Widget.TextView">
<item name="android:textColor">#color/second_text</item>
</style>
<style name="CrossfitEditText" parent="#android:style/Widget.EditText">
<item name="android:textSize">16sp</item>
<item name="android:maxLines">1</item>
<item name="android:textColor">#color/white</item>
<item name="android:textColorHint">#color/text_color</item>
</style>
<style name="Crossfit.Button" parent="Widget.AppCompat.Button.Colored">
<item name="colorButtonNormal">#color/colorPrimary</item>
<item name="colorControlHighlight">#color/colorPrimary</item>
<item name="android:textColor">#color/white</item>
<item name="android:paddingLeft">10dp</item>
<item name="android:paddingRight">10dp</item>
<item name="android:gravity">center</item>
</style>
<style name="Crossfit.F" parent="Widget.AppCompat.Button.Colored">
<item name="colorButtonNormal">#color/com_facebook_button_background_color</item>
<item name="colorControlHighlight">#color/com_facebook_button_background_color</item>
<item name="android:textColor">#color/white</item>
<item name="android:textAllCaps">false</item>
<item name="android:paddingLeft">10dp</item>
<item name="android:paddingRight">10dp</item>
<item name="android:gravity">center</item>
<item name="android:drawableLeft">#drawable/com_facebook_button_icon</item>
</style>
<style name="Crossfit.V" parent="Widget.AppCompat.Button.Colored">
<item name="colorButtonNormal">#color/vk_share_blue_color</item>
<item name="colorControlHighlight">#color/vk_share_blue_color</item>
<item name="android:textColor">#color/white</item>
<item name="android:textAllCaps">false</item>
<item name="android:paddingLeft">10dp</item>
<item name="android:paddingRight">10dp</item>
<item name="android:gravity">center</item>
<item name="android:drawableLeft">#drawable/com_facebook_button_icon</item>
</style>
<style name="CustomActionBar" parent="#style/ThemeOverlay.AppCompat.Dark.ActionBar">
<item name="android:windowActionBarOverlay">true</item>
<!-- Support library compatibility -->
<item name="windowActionBarOverlay">true</item>
</style>
<style name="AppTheme" parent="AppTheme.Base">
<!-- Customize your theme here. -->
<item name="android:colorPrimary">#color/colorPrimary</item>
<item name="android:colorPrimaryDark">#color/colorPrimaryDark</item>
<item name="android:colorAccent">#color/colorAccent</item>
<item name="android:textColorPrimary">#color/colorPrimary</item>
<item name="android:windowBackground">#color/colorAccent</item>
<item name="android:navigationBarColor">#color/colorPrimary</item>
</style>
<style name="MyTheme.Detail" parent="MyTheme">
<item name="android:statusBarColor">#android:color/transparent</item>
</style>
<style name="cfButton" parent="Widget.AppCompat.Button.Colored">
<item name="colorButtonNormal">#color/colorPrimary</item>
<item name="android:colorButtonNormal">#color/colorPrimary</item>
<item name="colorControlHighlight">#color/colorPrimaryDark</item>
<item name="android:textColor">#android:color/white</item>
</style>
<style name="MenuButtonsSmall">
<item name="fab_size">mini</item>
<item name="fab_colorNormal">#color/end</item>
<item name="fab_colorPressed">#color/end</item>
<item name="fab_colorRipple">#color/end</item>
</style>
<style name="mytext" parent="#android:style/TextAppearance">
<item name="android:textColor">#color/text_color</item>
<item name="android:textColorHint">#color/text_color</item>
<item name="colorAccent">#color/text_color</item>
</style>
</resources>
Changes made in values/styles.xml
<style name="AppThemeSignIn" parent="Theme.AppCompat.Light.DarkActionBar">
<!-- Customize your theme here. -->
<item name="colorPrimary">#color/background</item>
<item name="colorPrimaryDark">#color/background</item>
<item name="colorAccent">#color/colorAccent</item>
</style>
final styles in values/styles.xml
<resources>
<style name="CrossfitTextView" parent="#android:style/Widget.TextView">
<item name="android:textColor">#color/text_color</item>
</style>
<style name="CrossfitEditText" parent="#android:style/Widget.EditText">
<item name="android:textColor">#color/text_color</item>
<item name="android:textColorHint">#color/text_color</item>
</style>
<!-- Base application theme. -->
<style name="AppTheme.Base" parent="Theme.AppCompat.Light.NoActionBar">
</style>
<style name="AppTheme" parent="AppTheme.Base">
<!-- Customize your theme here. -->
<item name="colorPrimary">#color/colorPrimary</item>
<item name="colorPrimaryDark">#color/colorPrimaryDark</item>
<item name="colorAccent">#color/colorAccent</item>
<item name="windowActionBar">false</item>
<item name="windowNoTitle">true</item>
</style>
<style name="AppTheme.AppBarOverlay" parent="ThemeOverlay.AppCompat.Dark.ActionBar" />
<style name="AppTheme.PopupOverlay" parent="ThemeOverlay.AppCompat.Light" />
<style name="MaterialDialogSheet" parent="#android:style/Theme.Dialog">
<item name="android:windowIsTranslucent">true</item>
<item name="android:windowBackground">#android:color/transparent</item>
<item name="android:windowContentOverlay">#null</item>
<item name="android:windowNoTitle">true</item>
<item name="android:backgroundDimEnabled">true</item>
<item name="android:windowIsFloating">false</item>
<item name="android:windowAnimationStyle">#style/MaterialDialogSheetAnimation</item>
</style>
<style name="MaterialDialogSheetAnimation">
<item name="android:windowEnterAnimation">#anim/popup_show</item>
<item name="android:windowExitAnimation">#anim/popup_hide</item>
</style>
<style name="MenuButtonsSmall">
<item name="fab_size">mini</item>
<item name="fab_colorNormal">#026158</item>
<item name="fab_colorPressed">#026158</item>
<item name="fab_colorRipple">#026158</item>
</style>
<style name="MenuButtonNormal">
<item name="fab_size">normal</item>
<item name="fab_colorNormal">#026158</item>
<item name="fab_colorPressed">#026158</item>
<item name="fab_colorRipple">#026158</item>
</style>
</resources>
Are you using Vector images?
If you are try replacing all your android:src to app:srcCompat (when you are referring to a Vector image)