i need to do this :
http://developer.android.com/design/material/images/card_travel.png
so i create and add the dependency to the project and here is my activity main code:
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:id="#+id/feed_detail"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical">
<android.support.v7.widget.CardView
android:layout_height="wrap_content"
android:layout_width="match_parent"
android:layout_margin="6dp">
<ImageView
android:layout_width="100dp"
android:layout_height="50dp"
android:src="#drawable/ic"/>
<TextView
style="#style/TextAppearance.AppCompat.Caption"
android:textColor="#555"
android:layout_margin="3dp"
android:gravity="end"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="Detail"/>
</android.support.v7.widget.CardView>
</LinearLayout>
so, how we can do this like below picture:?
http://i.stack.imgur.com/Z0lNa.png
Cheers!
What you're looking for is a translucent status bar. When you have this configured you're able achieve this effect. Make also sure to remove the actionbar as I do in my example down below, otherwise you'll have to make it transparent.
Change your v21/themes.xml file to this:
<style name="Theme.MyTheme" parent="Theme.AppCompat.Light.NoActionBar">
<item name="android:statusBarColor">#android:color/transparent</item>
<item name="android:windowDrawsSystemBarBackgrounds">true</item>
<item name="android:windowTranslucentStatus">true</item>
</style>
Then add android:fitsSystemWindows="true" to your LinearLayout.
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:id="#+id/feed_detail"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical"
android:fitsSystemWindows="true">
Related
ShapeableImageView takes a ShapeAppearanceOverlay item in style to create desired shapes and sizes. The shape families are cut and rounded, radius can be used as a number or in percentages.
Here is my ShapeAppearanceOverlay theme for circularImageView:
<style name="ShapeAppearanceOverlay.App.circleImageView" parent="">
<item name="cornerFamily">cut</item>
<item name="cornerSize">50%</item>
</style>
Here Is the layout where I am using it:
<RelativeLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="#color/grey"
android:orientation="vertical">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="240dp" />
<!--Top Header Layout-->
<ScrollView
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_below="#+id/topbar"
android:scrollbars="none">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical">
<!--Top Profile Section -->
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content">
<com.google.android.material.imageview.ShapeableImageView
android:id="#+id/user_display_image"
style="#style/ShapeAppearanceOverlay.App.circleImageView"
android:layout_width="100dp"
android:layout_height="100dp"
android:src="#drawable/ic_user" />
</LinearLayout>
<androidx.fragment.app.FragmentContainerView
android:id="#+id/fragment_container"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:paddingBottom="#dimen/normal_bottom_margin" />
</LinearLayout>
</ScrollView>
</RelativeLayout>
Here is a screenshot of the issue:
Screenshot from IDE:
Use app:shapeAppearanceOverlay instead of style
<com.google.android.material.imageview.ShapeableImageView
app:shapeAppearanceOverlay="#style/ShapeAppearanceOverlay.App.circleImageView"
.../>
Or if you want to use it through style attribute :
<style name="Style.App.circleImageView" parent="">
<item name="shapeAppearance">#style/ShapeAppearanceOverlay.App.circleImageView</item>
</style>
<style name="ShapeAppearanceOverlay.App.circleImageView" parent="">
<item name="cornerFamily">cut</item>
<item name="cornerSize">50%</item>
</style>
...
<com.google.android.material.imageview.ShapeableImageView
android:id="#+id/user_display_image"
style="#style/Style.App.circleImageView"
android:layout_width="100dp"
android:layout_height="100dp"
android:src="#drawable/ic_user" />
...
I am developing android app and I want to add switch inside toolbar it is not showing
below is my xml
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:id="#+id/drawer_layout"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical">
<androidx.appcompat.widget.Toolbar
android:layout_width="match_parent"
android:layout_height="wrap_content">
<Switch
android:id="#+id/switch1"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="Switch" />
</androidx.appcompat.widget.Toolbar>
<androidx.recyclerview.widget.RecyclerView
android:id="#+id/recycler_view"
android:layout_width="match_parent"
android:layout_height="match_parent">
</androidx.recyclerview.widget.RecyclerView>
</LinearLayout>
following screen current ui
I want to know how to achieve that kind of ui what I have to do
Simply Change AppTheme to NoActionBar from styles.xml
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>
</style>
</resources>
Now run your app, switch will show on the top in Toolbar.
You need to use custom toolbar which you are already using in your xml file but you need to remove your default toolbar by calling getSupportActionBar().hide(); in activity onCreate(). and set the color of toolbar in xml
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:id="#+id/drawer_layout"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical">
<androidx.appcompat.widget.Toolbar
android:elevation="#dimen/margin_large"
android:background="#color/colorPrimaryDark"
android:layout_width="match_parent"
android:layout_height="wrap_content">
<Switch
android:id="#+id/switch1"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="Switch" />
</androidx.appcompat.widget.Toolbar>
<androidx.recyclerview.widget.RecyclerView
android:id="#+id/recycler_view"
android:layout_width="match_parent"
android:layout_height="match_parent">
</androidx.recyclerview.widget.RecyclerView>
I have a UI design to create where the toolbar is immersed within the recyclerview.
I have created the design but the lines of the layout are still visible on device whereas it appears to be right in the emulator. How do I merge the layout line in recyclerview.
Below is a screenshot from emulator
and below is a screenshot from my device
<?xml version="1.0" encoding="utf-8"?>
<androidx.coordinatorlayout.widget.CoordinatorLayout 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:layout_height="match_parent"
tools:context=".MainActivity">
<com.google.android.material.appbar.AppBarLayout
android:layout_width="match_parent"
android:background="#android:color/transparent"
android:layout_height="wrap_content">
<androidx.appcompat.widget.Toolbar
android:id="#+id/toolbar"
android:elevation="0dp"
android:background="#android:color/transparent"
android:layout_width="match_parent"
android:layout_height="?attr/actionBarSize"
android:layout_weight="100"
app:layout_scrollFlags="scroll|enterAlways">
<LinearLayout
android:layout_width="match_parent"
android:weightSum="100"
android:background="#android:color/transparent"
android:layout_height="match_parent">
<TextView
android:id="#+id/toolbar_title"
android:layout_width="0dp"
android:gravity="center"
android:layout_weight="80"
android:layout_height="match_parent"
android:text="#string/app_name"
android:textColor="#android:color/black"
android:textSize="25sp"
android:textStyle="bold" />
<ImageView
android:layout_width="0dp"
android:layout_height="60dp"
android:layout_weight="20"
android:layout_gravity="right"
android:src="#drawable/ic_add_black_24dp" />
</LinearLayout>
</androidx.appcompat.widget.Toolbar>
</com.google.android.material.appbar.AppBarLayout>
<androidx.recyclerview.widget.RecyclerView
android:id="#+id/my_recycler_view"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_marginTop="20dp"
android:background="#android:color/transparent"
android:scrollbars="vertical"
app:layout_behavior="#string/appbar_scrolling_view_behavior" />
</androidx.coordinatorlayout.widget.CoordinatorLayout>
That line is a shadow, caused by the Toolbar's elevation. Elevation only happens automatically on devices running Lollipop or newer, and the layout preview often doesn't show shadows.
Try adding this attribute to your Toolbar's XML to remove the elevation (and therefore the shadow):
android:elevation="0dp"
The most concise answer and easiest way to remove hide ToolBar Layout line/divider adding this line in your style.xml file inside the AppTheme style or whatever theme style you declared for your activity:
<item name="android:showDividers">none</item>
then your should look something like this
<!-- Base application theme. -->
<style name="AppTheme" parent="Theme.AppCompat.Light.NoActionBar">
<!-- Customize your theme here. -->
...
<item name="android:showDividers">none</item>
<!-- This line is not compulsory -->
<item name="actionBarDivider">#android:color/transparent</item>
<!-- This line is not compulsory -->
...
</style>
I hope this helps. it worked for me tho
Result: here's a screenshot of a typical example:
hello i have project that use multiple activity and xml one of this xml is navigation drawer it's easy to change backgournd color of actionbar/toolbar but when i change it on the other layout/xml background actionbar/tooolbar not change how to change all of them it's
Screenshot
screenshot
on this change
<?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"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:fitsSystemWindows="true"
tools:context="ir.diamonddesign.tajrobi96.MainActivity">
<android.support.design.widget.AppBarLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:theme="#style/AppTheme.AppBarOverlay">
<android.support.v7.widget.Toolbar
android:id="#+id/toolbar"
android:layout_width="match_parent"
android:layout_height="?attr/actionBarSize"
android:background="#android:color/holo_red_dark"
app:popupTheme="#style/AppTheme.PopupOverlay"
/>
</android.support.design.widget.AppBarLayout>
<include layout="#layout/content_main" />
</android.support.design.widget.CoordinatorLayout>
on this not change
/*
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:paddingBottom="#dimen/activity_vertical_margin"
android:paddingLeft="#dimen/activity_horizontal_margin"
android:paddingRight="#dimen/activity_horizontal_margin"
android:paddingTop="#dimen/activity_vertical_margin"
tools:context="ir.diamonddesign.tajrobi96.Questionsactivity"
>
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textSize="15dp"
android:textAppe``arance="?android:attr/textAppearanceLarge"
android:text="#string/kharej_text"
android:id="#+id/textView2"
android:textDirection="rtl"
android:layout_alignTop="#+id/textView3"
android:layout_alignParentLeft="true"
android:layout_alignParentStart="true" />
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textAppearance="?android:attr/textAppearanceLarge"
android:text="#string/dakhel_text"
android:textSize="15dp"
android:id="#+id/textView3"
android:layout_alignParentTop="true"
android:layout_alignParentRight="true"
android:layout_alignParentEnd="true"
android:layout_alignParentBottom="false"
android:textDirection="rtl" />
</RelativeLayout>*/
Find the file named styles.xml in your res folder.
You should have defined a theme for your project which looks something like below code
<style name="AppTheme" parent="Theme.AppCompat.Light.DarkActionBar">
<!-- Customize your theme here. -->
<item name="colorPrimary">#color/text_description</item>
<item name="colorPrimaryDark">#color/black</item>
<item name="colorAccent">#color/theme_teal</item>
</style>
Here, colorPrimary defines the color of your actionBar. This color must have been set to blue acc to the screenshot.
Try changing the colorPrimary value to the desired color that you want.
Change style.xml:
<item name="colorPrimary">#color/colorPrimary</item>
to :
<item name="colorPrimary">#android:color/holo_red_dark</item>
I have been trying to get my app to look more material(ized) with the help of app compat v21, I have replaced my regular actionbar with the support toolbar, and changed my theme to Theme.AppCompat.Light.NoActionBar this works great! However, when I longpress an item in my gridview and my actionmode bar (is that what they are called?) shows up for multi select it shows above the toolbar.
I want it to overlap the toolbar, the same way it did with my old regular actionbar. I have tried to find a solution here, and have found multiple sources saying to add true
This does not work for me, i have tried both with the android: prefix and without, but still I get the same result. My activity extends ActionBarActivity and I have put:
Toolbar toolbar = (Toolbar)findViewById(R.id.toolbar);
setSupportActionBar(toolbar);
In my onCreate. I feel like I have tried anything but I get the same result regardless.
I guess I better show some code:
My main layout
<android.support.v4.widget.DrawerLayout
xmlns:ads="http://schemas.android.com/apk/res-auto"
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:id="#+id/drawer_layout"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:fitsSystemWindows="true"
>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical"
android:background="?window_bg_default"
>
<!-- The main content view -->
<include layout="#layout/toolbar" />
<RelativeLayout
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:orientation="vertical"
>
<com.google.android.gms.ads.AdView
android:id="#+id/adView"
ads:adSize="SMART_BANNER"
android:visibility="gone"
android:background="#color/text_darkgray"
android:layout_width="fill_parent"
android:layout_alignParentBottom="true"
android:layout_height="wrap_content" />
<TableLayout
android:layout_height="fill_parent"
android:layout_width="fill_parent"
android:id="#+id/main_content"
android:layout_above="#id/adView"
/>
</RelativeLayout>
</LinearLayout>
<!-- The navigation drawer -->
<include layout="#layout/navdrawer" />
My styles
<style name="AppTheme" parent="Theme.AppCompat.Light.NoActionBar">
<item name="windowActionBar">false</item>
<item name="windowActionBarOverlay">true</item>
<item name="android:windowActionBarOverlay">true</item>
<item name="colorPrimary">#color/twee_orange_light</item>
<item name="colorPrimaryDark">#color/twee_orange_dark</item>
<item name="colorAccent">#color/twee_blue_light</item>
<item name="android:windowActionBar">false</item>
<item name="android:windowActionModeOverlay">true</item>
<item name="windowActionModeOverlay">true</item>
<item name="android:actionBarStyle">#style/AppTheme.Actionbar</item>
<item name="android:actionModeBackground">#color/twee_orange_dark</item>
<item name="android:actionOverflowButtonStyle">#style/AppTheme.Overflow</item>
<item name="android:homeAsUpIndicator">#drawable/ic_action_home</item>
<item name="card_bg_default">#drawable/img_bg_card</item>
<item name="window_bg_default">#drawable/window_background</item>
<item name="card_episode_name">#color/nextepisodegray</item>
<item name="card_episode_number">#color/twee_black</item>
<item name="button_bg">?android:attr/selectableItemBackground</item>
<item name="button_watched">#drawable/ic_watched_inactive</item>
<item name="text_default">#color/text_slightlydarkgray</item>
<item name="text_default_header">#color/text_darkergray</item>
<item name="text_season_separator">#color/black</item>
<item name="drawer_background">#color/drawer_background</item>
<item name="drawer_list_background">#color/drawer_list_background</item>
<item name="card_bg_default_color">#color/drawer_list_background</item>
<item name="twee_divider">#color/divider_default</item>
<item name="card_header_default">#drawable/img_bg_cardtop_header</item>
<item name="checkbox_watched">#drawable/checkbox_watched</item>
<item name="card_middle_bg">#drawable/background_listitem_default</item>
</style>
My toolbar:
<android.support.v7.widget.Toolbar
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:id="#+id/toolbar"
android:layout_height="wrap_content"
android:layout_width="match_parent"
android:minHeight="?attr/actionBarSize"
android:background="#color/twee_orange_light"
app:theme="#style/ThemeOverlay.AppCompat.Dark.ActionBar"
app:popupTheme="#style/ThemeOverlay.AppCompat.Light"
android:elevation="8dp" />
My navdrawer:ยจ
<se.ja1984.twee.Activities.Views.ScrimInsetsScrollView
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:layout_width="#dimen/navigation_drawer_width"
android:layout_height="fill_parent"
android:layout_gravity="left|start"
android:orientation="vertical"
android:id="#+id/drawer_wrapper"
android:background="?drawer_background"
android:fitsSystemWindows="true"
app:insetForeground="#4000"
>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical"
>
<FrameLayout
android:layout_width="fill_parent"
android:layout_height="165dp"
android:background="#drawable/img_navdrawer_header"
android:orientation="vertical"
android:paddingLeft="16dp"
android:paddingRight="16dp"
android:paddingTop="#dimen/navbar_top"
android:paddingBottom="8dp"
android:id="#+id/lnrProfileChooser"
>
<FrameLayout
android:layout_width="match_parent"
android:layout_height="wrap_content">
<RelativeLayout
android:id="#+id/layoutImage"
android:layout_width="64dp"
android:layout_height="64dp"
android:layout_marginRight="#dimen/padding_small"
>
<se.ja1984.twee.utils.RoundedImageView
style="#style/Twee_Cast_Photo"
android:layout_height="64dp"
android:layout_width="64dp"
android:id="#+id/imgUser"
android:scaleType="centerCrop"
android:src="#drawable/ic_no_cast"/>
<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:id="#+id/traktWrapper"
android:layout_width="20dp"
android:layout_height="20dp"
android:layout_alignParentBottom="true"
android:layout_alignParentRight="true"
android:layout_alignParentEnd="true"
android:visibility="gone"
>
<ImageView
android:id="#+id/background"
android:layout_width="20dp"
android:layout_height="20dp"
android:src="#drawable/trakt_background"
/>
<ImageView
android:layout_gravity="center"
android:id="#+id/imgTraktLogo"
android:layout_width="10dp"
android:layout_height="10dp"
android:src="#drawable/ic_trakt_logo"
/>
</FrameLayout>
</RelativeLayout>
<it.sephiroth.android.library.widget.HListView
android:id="#+id/profiles"
android:layout_width="48dp"
android:layout_height="wrap_content"
android:layout_alignParentRight="true"
android:layout_gravity="right|top" />
</FrameLayout>
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="50dp"
android:orientation="vertical"
android:layout_gravity="bottom"
>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content" android:orientation="vertical"
android:layout_alignParentBottom="true"
>
<TextView
style="#style/Twee_Profile_Displayname"
android:id="#+id/txtUsername"
android:text="#string/profile_notsignedin_displayname"
android:paddingTop="0dp"
/>
<TextView
android:text="Xxxx hours well spent"
style="#style/Twee_Profile_Timewasted"
android:id="#+id/txtTimeWasted"
android:paddingTop="0dp"
android:layout_below="#+id/txtUsername" />
</LinearLayout>
</RelativeLayout>
</FrameLayout>
<LinearLayout
android:id="#+id/navdrawer_items_list"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="8dp"
android:layout_marginBottom="8dp"
android:orientation="vertical" />
</LinearLayout>
</se.ja1984.twee.Activities.Views.ScrimInsetsScrollView>
The trained eyes might see that I have borrowed the ScrimInsetScrollView from the IOSched app, but I don't think that matters.
And here's an image of the monsterosity!
I managed to solve this issue myself!
The problem is that I ran my super.onCreate() to late in my onCreate method.
I moved it to the top of my method, and now it works great!