i'm trying to run the project and its really cool in Lollipop devices(designs and etc.without any problem)
But there is a problem in this project and i havent any experiences about this compatiblity in Kitkat.after installing:
http://i.imgur.com/KSYkyeu.png
I'm using : https://github.com/AkashBang/NavigationView
and here is the activty main:
<android.support.v4.widget.DrawerLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:card_view="http://schemas.android.com/apk/res-auto"
xmlns:custom="http://schemas.android.com/tools"
xmlns:tools="http://schemas.android.com/tools"
android:id="#+id/drawer"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:fitsSystemWindows="true"
tools:context=".MainActivity">
<android.support.v4.widget.SwipeRefreshLayout
android:id="#+id/swipe_refresh_layout"
android:layout_width="match_parent"
android:layout_height="match_parent">
<ScrollView
android:layout_width="match_parent"
android:layout_height="match_parent">
<LinearLayout
android:id="#+id/v"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical"
android:weightSum="1">
<include
android:id="#+id/toolbar"
layout="#layout/tool_bar">
</include>
<com.daimajia.slider.library.SliderLayout
android:id="#+id/slider"
android:layout_width="match_parent"
android:layout_height="175dp"
android:elevation="2dp"
custom:auto_cycle="true"
custom:indicator_visibility="invisible"
custom:pager_animation="Accordion"
custom:pager_animation_span="1000" />
<Button
android:id="#+id/btncat"
android:layout_width="300dp"
android:layout_height="55dp"
android:layout_gravity="center"
android:drawableStart="#drawable/ic_home"
android:paddingEnd="40dp"
android:paddingStart="20sp"
android:text="#string/category"
android:textColor="#FFFFFF"
android:textDirection="ltr" />
<android.support.v7.widget.CardView
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_marginLeft="9dp"
android:layout_marginRight="9dp"
android:layout_marginTop="1dp"
android:clickable="true"
android:foreground="?android:attr/selectableItemBackground"
card_view:cardCornerRadius="3dp"
card_view:cardElevation="3sp"
card_view:cardUseCompatPadding="true">
</android.support.v7.widget.CardView>
<RelativeLayout
android:id="#+id/top_layout"
android:layout_width="match_parent"
android:layout_height="match_parent">
<TextView
android:id="#+id/textView"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentTop="true"
android:layout_alignStart="#+id/cardview1"
android:layout_marginTop="30dp"
android:text="#string/rcrechome"
android:textAppearance="?android:attr/textAppearanceLarge" />
<android.support.v7.widget.CardView
android:id="#+id/cardview1"
android:layout_width="120dp"
android:layout_height="180dp"
android:layout_below="#+id/textView"
android:layout_marginEnd="9dp"
android:layout_marginStart="7dp"
android:layout_marginTop="20dp"
android:clickable="true"
android:foreground="?android:attr/selectableItemBackground"
card_view:cardCornerRadius="3dp"
card_view:cardElevation="3sp"
card_view:cardUseCompatPadding="true" />
<android.support.v7.widget.CardView
android:id="#+id/cardview2"
android:layout_width="120dp"
android:layout_height="180dp"
android:layout_alignTop="#+id/cardview1"
android:layout_centerHorizontal="true"
android:clickable="true"
android:foreground="?android:attr/selectableItemBackground"
card_view:cardCornerRadius="3dp"
card_view:cardElevation="3sp"
card_view:cardUseCompatPadding="true" />
<android.support.v7.widget.CardView
android:id="#+id/cardview3"
android:layout_width="120dp"
android:layout_height="180dp"
android:layout_alignParentEnd="true"
android:layout_alignTop="#+id/cardview2"
android:layout_marginEnd="7dp"
android:clickable="true"
android:foreground="?android:attr/selectableItemBackground"
card_view:cardCornerRadius="3dp"
card_view:cardElevation="3sp"
card_view:cardUseCompatPadding="true" />
<Button
android:id="#+id/button"
style="?android:attr/buttonStyleSmall"
android:layout_width="70dp"
android:layout_height="40dp"
android:layout_alignBaseline="#+id/textView"
android:layout_alignBottom="#+id/textView"
android:layout_alignEnd="#+id/cardview3"
android:text="#string/morebtn"
android:textColor="#ffffff" />
</RelativeLayout>
</LinearLayout>
</ScrollView>
</android.support.v4.widget.SwipeRefreshLayout>
<android.support.design.widget.NavigationView
android:id="#+id/navigation_view"
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:layout_gravity="start"
app:headerLayout="#layout/header"
app:menu="#menu/drawer" />
</android.support.v4.widget.DrawerLayout>
Theme: for this activity
<style name="AppTheme" parent="Theme.AppCompat.Light.NoActionBar">
<item name="colorPrimaryDark">#color/colorPrimaryDark</item>
<item name="colorPrimary">#color/ColorPrimary</item>
<item name="windowActionBar">false</item>
<item name="windowActionModeOverlay">true</item>
<item name="android:windowTranslucentStatus">true</item>
<item name="android:colorButtonNormal">#43A047</item>
<!-- Customize your theme here. -->
</style>
Toolbar codes:
<?xml version="1.0" encoding="utf-8"?>
<android.support.v7.widget.Toolbar 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="?attr/actionBarSize"
android:background="#color/ColorPrimary"
app:theme="#style/ThemeOverlay.AppCompat.Dark.ActionBar" />
But, i cant figured out, why this is gonna happened?
Cheers!
After deleting this in V19 Layout and style, its working.
<item name="android:windowTranslucentStatus">true</item>
Related
I am using these following theme for my app.
But I cannot find out the reason why some portion has cropped.
<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>
<item name="alertDialogTheme">#style/MyAlertDialogStyle</item>
<item name="alertDialogStyle">#style/MyAlertDialogStyle</item>
<item name="android:windowBackground">#drawable/background_splash</item>
</style>
Here is the screenshot of my app User interface. The border sides are cropped.
Here is my activity_main.XML
<?xml version="1.0" encoding="utf-8"?>
<FrameLayout 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:background="#color/White"
tools:context="com.ff.foodbio.MainActivity">
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="match_parent">
<RelativeLayout
android:id="#+id/reloadLayout"
android:layout_width="match_parent"
android:background="#000"
android:layout_height="45dp">
<ImageView
android:id="#+id/btnReload"
android:layout_width="20dp"
android:layout_height="match_parent"
android:layout_marginLeft="20dp"
android:src="#drawable/reload"
android:layout_alignParentLeft="true"
android:tint="#fff"
android:visibility="gone"
android:scaleType="fitCenter"/>
<TextView
android:layout_width="fill_parent"
android:layout_height="match_parent"
android:layout_toRightOf="#+id/btnReload"
android:layout_toLeftOf="#+id/settings"
android:textSize="20sp"
android:textColor="#fff"
android:gravity="center"
android:visibility="gone"
android:text="Food BIO"/>
<ImageView
android:layout_width="100dp"
android:layout_height="match_parent"
android:src="#drawable/foodbio_text"
android:layout_centerInParent="true"
android:gravity="center"/>
<ImageView
android:id="#+id/settings"
android:layout_alignParentRight="true"
android:layout_width="30dp"
android:layout_marginRight="20dp"
android:layout_height="match_parent"
android:tint="#fff"
android:src="#drawable/menu"
android:scaleType="fitCenter"/>
</RelativeLayout>
<RelativeLayout
android:id="#+id/tabLayout"
android:layout_width="wrap_content"
android:layout_height="55dp"
android:background="#color/Black"
android:layout_below="#+id/reloadLayout">
<android.support.v7.widget.RecyclerView
android:id="#+id/tabRecyclerView"
android:layout_width="wrap_content"
android:clipToPadding="false"
android:background="#color/Black"
android:layout_height="match_parent">
</android.support.v7.widget.RecyclerView>
</RelativeLayout>
<RelativeLayout
android:id="#+id/separatorBar"
android:layout_width="match_parent"
android:layout_below="#+id/tabLayout"
android:layout_marginTop="-2dp"
android:layout_height="5dp">
</RelativeLayout>
<FrameLayout
android:id="#+id/root_fragment_one"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_below="#+id/separatorBar">
</FrameLayout>
</RelativeLayout>
</FrameLayout>
I could not find out the problem. What is the wrong with my code?
How can I solve this problem?
i am trying to add a custom tool bar
this is my toolbar.xml
<?xml version="1.0" encoding="utf-8"?>
<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"
app:theme="#style/ThemeOverlay.AppCompat.Dark.ActionBar"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:minHeight="?attr/actionBarSize"
app:subtitleTextColor="#color/sub_text_color"
app:navigationContentDescription="#string/abc_action_bar_up_description"
android:background="#color/sub_text_color"
app:navigationIcon="?attr/homeAsUpIndicator"
/>
this is my style
<!-- 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>
i have included it in my activity main
<RelativeLayout 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="com.example.myproj.activities.RegisterActivity">
<include layout="#layout/toolbar"/>
in my main activity class i called
#Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_register);
toolbar = findViewById(R.id.toolbar);
setSupportActionBar(toolbar);
toolbar.setTitle(R.string.create_account);
}
but still i am not able to see the toolbar in my class.
Can some one help me to figure out the error
Use LinearLayout as parent , the child layout might be hiding the toolBar
<LinearLayout 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="com.example.myproj.activities.RegisterActivity">
<include layout="#layout/toolbar"/>
//other childs
</LinearLayout>
To set title to tool bar use getSupportActionBar().setTitle(title);
toolbar = findViewById(R.id.toolbar);
setSupportActionBar(toolbar);
getSupportActionBar().setTitle(title);
Quite a number of things could be responsible for this.
Firstly, It is possible that the views placed after the custom toolbar are overlayed on it, hence blocking it from view. Remenber that you are using RelativeLayout as your root element. So you'll want to ensure that views after the toolbar have android:layout_below="#+id/toolbar" attribute.
Secondly, I'll advice you to use a coordinator layout as your rootview and wrap your custom toolbar in AppBarLayout view. So that your layout file resembles this:
<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"
tools:context="ng.shoppi.lafarge_app.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="?attr/colorPrimary"
app:popupTheme="#style/AppTheme.PopupOverlay" />
</android.support.design.widget.AppBarLayout>
<include
android:id="#+id/content_main"
layout="#layout/content_main" />
This will keep the toolbar at the top and ensure other views are below the toolbar.
Goodluck.
Try this,
<?xml version="1.0" encoding="utf-8"?>
<android.support.design.widget.AppBarLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:id="#+id/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="?actionBarSize"
android:background="?attr/colorPrimary"
app:contentInsetStartWithNavigation="0dp"
app:popupTheme="#style/AppTheme.PopupOverlay">
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:gravity="center_vertical">
<com.itc.classmate.utils.FontTextView
android:id="#+id/textview_toolbar_title"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentLeft="true"
android:layout_centerVertical="true"
android:layout_marginLeft="#dimen/gap_btn_logo"
android:layout_toLeftOf="#+id/rel_toolbar_options"
android:ellipsize="marquee"
android:paddingRight="5dp"
android:singleLine="true"
android:text=""
android:textColor="#color/colorWhite"
android:textSize="#dimen/comm_text_size_normal" />
<LinearLayout
android:id="#+id/rel_toolbar_options"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerVertical="true"
android:layout_toLeftOf="#+id/rel_toolbar_right_cornor_item"
android:gravity="center_vertical">
<ImageView
android:id="#+id/imgview_toolbar_share"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center_vertical"
android:layout_marginRight="#dimen/toolbar_notification_right_margin"
android:layout_toLeftOf="#+id/imgview_toolbar_choose_class"
android:padding="#dimen/inc_toolbar_icon_padding"
android:src="#drawable/ic_menu_share"
android:visibility="gone" />
<ImageView
android:id="#+id/imgview_toolbar_choose_class"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center_vertical"
android:layout_marginRight="#dimen/toolbar_notification_right_margin"
android:layout_toLeftOf="#+id/imgview_toolbar_edit"
android:padding="#dimen/inc_toolbar_icon_padding"
android:src="#drawable/selectclass"
android:visibility="gone" />
<ImageView
android:id="#+id/imgview_toolbar_edit"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center_vertical"
android:layout_marginRight="#dimen/toolbar_notification_right_margin"
android:layout_toLeftOf="#+id/imgview_toolbar_done"
android:padding="#dimen/inc_toolbar_icon_padding"
android:src="#drawable/profile_edit_icon"
android:visibility="gone" />
<ImageView
android:id="#+id/imgview_toolbar_done"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center_vertical"
android:layout_marginRight="14dp"
android:layout_toLeftOf="#+id/textview_toolbar_delete_bookmark"
android:padding="#dimen/inc_toolbar_icon_padding"
android:src="#drawable/done"
android:visibility="gone" />
<com.itc.classmate.utils.FontTextView
android:id="#+id/textview_toolbar_delete_bookmark"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center_vertical"
android:layout_marginRight="14dp"
android:layout_toLeftOf="#+id/imageview_toolbar_delete"
android:padding="#dimen/inc_toolbar_icon_padding"
android:text="#string/clear_all"
android:textColor="#color/colorWhite"
android:textSize="#dimen/comm_text_size_mediam"
android:visibility="gone" />
<ImageView
android:id="#+id/imageview_toolbar_delete"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center_vertical"
android:layout_marginRight="14dp"
android:layout_toLeftOf="#+id/textview_toolbar_done"
android:padding="#dimen/inc_toolbar_icon_padding"
android:src="#drawable/delete"
android:visibility="gone" />
<com.itc.classmate.utils.FontTextView
android:id="#+id/textview_toolbar_done"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center_vertical"
android:layout_marginRight="#dimen/toolbar_notification_right_margin"
android:layout_toLeftOf="#+id/imgview_toolbar_notification"
android:padding="#dimen/inc_toolbar_icon_padding"
android:text="Done"
android:textColor="#color/colorWhite"
android:textSize="#dimen/comm_text_size_normal"
android:visibility="gone"
app:textAllCaps="true" />
<RelativeLayout
android:id="#+id/rl_notification"
android:layout_width="wrap_content"
android:layout_height="?actionBarSize"
android:layout_marginRight="#dimen/toolbar_notification_right_margin"
>
<ImageView
android:id="#+id/imgview_toolbar_notification"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerVertical="true"
android:padding="#dimen/inc_toolbar_icon_padding"
android:src="#drawable/bell"
android:visibility="gone" />
<TextView
android:id="#+id/txtview_toolbar_notification"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textColor="#color/colorWhite"
android:background="#drawable/shape_notification_dot"
android:textSize="#dimen/comm_text_size_very_small"
android:padding="2dp"
android:gravity="center"
android:visibility="gone"
android:layout_marginTop="10dp"
android:layout_marginStart="10dp"/>
</RelativeLayout>
</LinearLayout>
<RelativeLayout
android:id="#+id/rel_toolbar_right_cornor_item"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentRight="true"
android:layout_centerInParent="true"
android:layout_marginRight="#dimen/toolbar_notification_right_margin"
android:padding="#dimen/inc_toolbar_icon_padding"
android:visibility="visible">
<com.itc.classmate.utils.CircularImage
android:id="#+id/imgview_toolbar_profile"
android:layout_width="#dimen/toolbar_profile_width_height"
android:layout_height="#dimen/toolbar_profile_width_height"
android:layout_centerInParent="true"
android:src="#drawable/profile_icon"
android:visibility="invisible" />
<com.itc.classmate.utils.FontTextView
android:id="#+id/textview_toolbar_save"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerInParent="true"
android:text="#string/save"
android:textColor="#color/colorWhite"
android:textSize="#dimen/comm_text_size_mediam"
android:visibility="gone"
app:textAllCaps="true" />
<ImageView
android:id="#+id/imgview_toolbar_delete"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerInParent="true"
android:layout_marginRight="#dimen/toolbar_notification_right_margin"
android:padding="#dimen/inc_toolbar_icon_padding"
android:src="#drawable/profile_delete_icon"
android:visibility="gone" />
</RelativeLayout>
</RelativeLayout>
</android.support.v7.widget.Toolbar>
</android.support.design.widget.AppBarLayout>
Try to remove theme in your custom toolbar:
<?xml version="1.0" encoding="utf-8"?>
<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"
app:theme="#style/ThemeOverlay.AppCompat.Dark.ActionBar" //REMOVE THIS
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:minHeight="?attr/actionBarSize"
app:subtitleTextColor="#color/sub_text_color"
app:navigationContentDescription="#string/abc_action_bar_up_description"
android:background="#color/sub_text_color"
app:navigationIcon="?attr/homeAsUpIndicator"
/>
i think the theme is influential....
Please update your code a bit:
Style:
<style name="AppTheme" parent="Theme.AppCompat.Light">
XML file:
<android.support.design.widget.AppBarLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:theme="#style/ThemeOverlay.AppCompat.Dark.ActionBar">
<android.support.v7.widget.Toolbar
android:id="#+id/toolbar"
android:layout_width="match_parent"
android:layout_height="?attr/actionBarSize"
android:background="?attr/colorPrimary"
app:popupTheme="#style/ThemeOverlay.AppCompat.Light" />
</android.support.design.widget.AppBarLayout>
In my placeOrder activity navigation drawer is not starting from the top side of device screen as you can see in the scrrenshot of emulator.
this is my xml file in which i have implemented navigation drawer.
<android.support.v4.widget.DrawerLayout
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:id="#+id/drawer_layout"
tools:context="com.e_prints.myapplication.PlaceOrder">
<FrameLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:id="#+id/nav_container"
>
<ScrollView
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_alignParentBottom="true">
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:id="#+id/container"
android:paddingBottom="#dimen/activity_vertical_margin"
android:paddingLeft="#dimen/activity_horizontal_margin"
android:paddingRight="#dimen/activity_horizontal_margin"
android:paddingTop="#dimen/activity_vertical_margin"
>
<TableLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:id="#+id/t_placeorder"
android:layout_width="fill_parent"
android:layout_height="fill_parent">
<TableRow>
<TextView
android:id="#+id/tv_psize"
android:text="#string/p_size"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="20dp"
android:layout_column="1"
/>
<Spinner
android:layout_width="200dp"
android:layout_height="wrap_content"
android:id="#+id/size"
android:entries="#array/paper_size"
android:layout_marginTop="20dp"
android:layout_marginLeft="20dp"
android:spinnerMode="dropdown"
android:layout_column="1" />
</TableRow>
<TableRow>
<TextView
android:id="#+id/tv_pcolor"
android:layout_width="wrap_content"
android:text="#string/p_color"
android:layout_height="wrap_content"
android:layout_marginTop="20dp"
android:layout_column="1"
/>
<Spinner
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:entries="#array/color"
android:id="#+id/color"
android:layout_column="2"
android:layout_marginLeft="20dp"
android:layout_marginTop="20dp"></Spinner>
</TableRow>
<TableRow>
<TextView
android:id="#+id/tv_pbinding"
android:layout_width="wrap_content"
android:text="#string/p_binding"
android:layout_height="wrap_content"
android:layout_marginTop="20dp"
android:layout_column="1"/>
<Spinner
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:id="#+id/binding"
android:entries="#array/binding"
android:layout_column="2"
android:layout_marginLeft="20dp"
android:layout_marginTop="20dp"
></Spinner>
</TableRow>
<TableRow>
<TextView
android:id="#+id/tv_ptype"
android:layout_width="wrap_content"
android:text="#string/p_type"
android:layout_height="wrap_content"
android:layout_marginTop="20dp"
android:layout_column="1"/>
<Spinner
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:id="#+id/type"
android:entries="#array/type"
android:layout_column="2"
android:layout_marginLeft="20dp"
android:layout_marginTop="20dp"
></Spinner>
</TableRow>
<TableRow>
<TextView
android:id="#+id/tv_pattach"
android:layout_width="wrap_content"
android:text="#string/p_attach"
android:layout_height="wrap_content"
android:layout_column="1"
android:layout_marginTop="20dp"
/>
<Button
android:id="#+id/b_browse"
android:layout_width="wrap_content"
android:layout_height="40dp"
android:background="#color/colorPrimary"
android:textColor="#color/white"
android:text="#string/b_browse"
android:layout_column="2"
android:layout_marginLeft="20dp"
android:layout_marginTop="20dp"
/>
</TableRow>
<TableRow>
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="#+id/selected"
android:layout_marginLeft="20dp"
android:layout_marginTop="20dp"
android:id="#+id/file_path"
android:text="#string/file_path"
android:layout_column="2"
/>
</TableRow>
<TableRow>
<TextView
android:id="#+id/tv_pncpoies"
android:layout_width="wrap_content"
android:text="#string/p_copies"
android:layout_height="wrap_content"
android:layout_marginTop="20dp"
android:layout_column="1"
/>
<EditText
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:id="#+id/et_ncpoies"
android:hint="#string/p_ncopies"
android:layout_column="2"
android:layout_marginLeft="20dp"
android:layout_marginTop="20dp"
/>
</TableRow>
<TableRow>
<TextView
android:id="#+id/tv_ppgnum"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="#string/pgnum"
android:layout_marginTop="20dp"
android:layout_column="1"
/>
<RadioGroup
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="20dp"
android:orientation="vertical"
android:id="#+id/radiogroup1"
android:layout_column="2"
android:layout_marginLeft="20dp"
>
<RadioButton
android:text="#string/Poption1"
android:id="#+id/rb_poption1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
/>
<RadioButton
android:text="#string/poption2"
android:id="#+id/rb_poption2"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
/>
</RadioGroup>
</TableRow>
<TableRow>
<EditText
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:id="#+id/custom_print"
android:hint="1-30,50,55,60-90,100"
android:layout_column="2"
android:layout_marginLeft="20dp"
android:visibility="invisible"
/>
</TableRow>
</TableLayout>
<RadioGroup
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="#+id/t_placeorder"
android:layout_marginTop="20dp"
android:orientation="horizontal"
android:id="#+id/radiogroup">
<RadioButton
android:text="#string/p_homed"
android:id="#+id/rb_home"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:onClick="onRadioButtonClicked"/>
<RadioButton
android:text="#string/pickup"
android:id="#+id/rb_pick"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:onClick="onRadioButtonClicked"
android:layout_marginLeft="50dp"
/>
</RadioGroup>
<LinearLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:id="#+id/address"
android:orientation="vertical"
android:layout_marginTop="20dp"
android:layout_below="#+id/radiogroup"
>
</LinearLayout>
<Button
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="#string/b_proceed"
android:id="#+id/b_proceed"
android:layout_below="#id/address"
android:layout_marginTop="20dp"
android:background="#color/colorPrimary"
android:textColor="#color/white"
android:onClick="OnOrder"
/>
</RelativeLayout>
</ScrollView>
</FrameLayout>
<android.support.design.widget.NavigationView
android:layout_width="match_parent"
android:layout_height="match_parent"
app:menu="#menu/nav_menu"
android:id="#+id/navigatiom_view"
android:layout_gravity="start"
android:fitsSystemWindows="true"
app:headerLayout="#layout/nav_header_main"/>
You need to make DrawerLayout as parent..Try this way it will help you
<?xml version="1.0" encoding="utf-8"?>
<android.support.v4.widget.DrawerLayout 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:id="#+id/drawer_layout"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:fitsSystemWindows="true"
tools:openDrawer="start">
<include
layout="#layout/app_bar_main"
android:layout_width="match_parent"
android:layout_height="match_parent" />
<android.support.design.widget.NavigationView
android:id="#+id/nav_view"
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:layout_gravity="start"
android:fitsSystemWindows="true"
app:headerLayout="#layout/nav_header_main"
app:menu="#menu/activity_main_drawer" />
</android.support.v4.widget.DrawerLayout>
http://www.androidhive.info/2013/11/android-sliding-menu-using-navigation-drawer/
New App Compat library support this feature all you need to do is use toolbar instead of Action bar its more customizable than action bar and relatively easy to use than Action bar.
Add this to your styles.xml
<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="dialogTheme">#style/Theme.Dialog</item>
</style>
<style name="AppTheme.AppBarOverlay" parent="ThemeOverlay.AppCompat.Dark.ActionBar" />
<style name="AppTheme.PopupOverlay" parent="ThemeOverlay.AppCompat.Dark" />
Apply this theme to your App in manifest.xml
<application
....
....
android:theme="#style/AppTheme">
Now create your layout like this
<?xml version="1.0" encoding="utf-8"?>
<android.support.design.widget.CoordinatorLayout xmlns:tools="http://schemas.android.com/tools"
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.support.v4.widget.DrawerLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:id="#+id/drawer_layout"
tools:openDrawer="start">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical">
<android.support.design.widget.AppBarLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:id="#+id/myAppBar"
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="?attr/colorPrimary"
app:popupTheme="#style/AppTheme.PopupOverlay"
app:title="Jewellery"/>
</android.support.design.widget.AppBarLayout>
<!--Your Layout Here-->
<RelativeLayout
android:id="#+id/main_content"
android:layout_width="match_parent"
android:layout_height="match_parent">
<ScrollView
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_above="#+id/tabs"
android:id="#+id/scroll"
android:scrollbars="none">
<FrameLayout
android:id="#+id/container"
android:layout_width="match_parent"
android:layout_height="wrap_content">
</FrameLayout>
</ScrollView>
</RelativeLayout>
<!-----Layout Ends-->
</LinearLayout>
<android.support.design.widget.NavigationView
android:id="#+id/nav_view"
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:layout_gravity="start"
android:fitsSystemWindows="true"
app:headerLayout="#layout/nav_header"/>
</android.support.v4.widget.DrawerLayout>
</android.support.design.widget.CoordinatorLayout>
Now in your Main Activity
Toolbar toolbar=(Toolbar) findViewById(R.id.toolbar);
setSupportActionBar(toolbar);
if(getSupportActionBar()!=null){
getSupportActionBar().setDisplayHomeAsUpEnabled(true);
getSupportActionBar().setHomeButtonEnabled(true);
}
DrawerLayout mDrawerLayout = (DrawerLayout) findViewById(R.id.drawer_layout);
ActionBarDrawerToggle mDrawerToggle = new ActionBarDrawerToggle(this, mDrawerLayout, R.string.drawer_open, R.string.drawer_close);
mDrawerLayout.addDrawerListener(mDrawerToggle);
mDrawerToggle.syncState();
Hello guys I have problem with NavigationBarView. I set NavigationBarView this without not swipe and I set Other view above NavigationBarView. I made this Activity with Tranculents Style. But I have got error, the notification bar is double, this drawed on top NavigationBarView.
This my XML:
<?xml version="1.0" encoding="utf-8"?>
<FrameLayout 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="com.ad.sample.ui.activity.HomeActivity">
<fragment
android:id="#+id/map"
android:name="com.google.android.gms.maps.SupportMapFragment"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:fitsSystemWindows="true">
</fragment>
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical">
<View
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignTop="#+id/btn_main_menu"
android:layout_alignBottom="#+id/navigation_view"
android:background="#color/biru"
android:layout_alignParentTop="true"
android:clickable="true"
android:soundEffectsEnabled="false" />
<android.support.design.widget.NavigationView
android:paddingLeft="8dp"
android:id="#+id/navigation_view"
android:layout_below="#+id/btn_main_menu"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="#color/biru"
app:itemTextColor="#color/white"
app:menu="#menu/main_menu" />
<android.support.design.widget.FloatingActionButton
android:id="#+id/btn_main_menu"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginBottom="10dp"
android:layout_marginLeft="10dp"
android:layout_marginRight="10dp"
android:layout_marginTop="#dimen/marginTopToolbar"
app:backgroundTint="#color/white"
app:elevation="1dp" />
</RelativeLayout>
</FrameLayout>
And this Style-v21
<style name="AppTheme.HomeActivity">
<item name="windowActionBar">false</item>
<item name="windowNoTitle">true</item>
<item name="android:windowDrawsSystemBarBackgrounds">true</item>
<item name="android:windowTranslucentStatus">true</item>
</style>
How to fix it?
Try this:- your code is working fine in mine case , looks like the problem of double notification bar is due to some other reason. But i have rectified your code.
<FrameLayout 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="com.ad.sample.ui.activity.HomeActivity">
<fragment
android:id="#+id/map"
android:name="com.google.android.gms.maps.SupportMapFragment"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:fitsSystemWindows="true">
</fragment>
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical"
>
<View
android:layout_width="wrap_content"
android:layout_height="1dp"
android:layout_above="#+id/btn_main_menu"
android:background="#color/blue"
android:clickable="true"
android:soundEffectsEnabled="false" />
<android.support.design.widget.NavigationView
android:paddingLeft="8dp"
android:id="#+id/navigation_view"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="#color/blue"
app:itemTextColor="#color/white"
app:menu="#menu/main_menu"
android:layout_alignParentBottom="true"
/>
<android.support.design.widget.FloatingActionButton
android:id="#+id/btn_main_menu"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginBottom="10dp"
android:layout_marginLeft="10dp"
android:layout_marginRight="10dp"
android:layout_marginTop="10dp"
app:backgroundTint="#color/white"
app:elevation="1dp"
android:layout_above="#+id/navigation_view"/>
</RelativeLayout>
</FrameLayout>
I have a problem, I can't center my title in my Toolbar (#+id/toolbar_title). I tried to put a RelativeLayout, use layout_gravity: center but it doesn't work. I have added colors to distinguish the layout but I can't post pictures yet.
http://hpics.li/72b1cf7
activity_main.xml
<android.support.v4.widget.DrawerLayout
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
xmlns:app="http://schemas.android.com/apk/res-auto"
tools:context=".MainActivity"
android:id="#+id/drawer_layout"
android:layout_width="match_parent"
android:layout_height="match_parent">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical">
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="wrap_content">
<android.support.v7.widget.Toolbar
android:id="#+id/toolbar"
android:layout_width="match_parent"
android:layout_height="60dp"
android:background="#android:color/holo_green_dark"
app:theme="#style/ToolbarTheme"
app:popupTheme="#style/Theme.AppCompat"
android:layout_gravity="center_vertical"
>
<TextView
android:id="#+id/toolbar_title"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerVertical="true"
android:layout_gravity="center"
android:background="#color/primaryDark"
android:textSize="20dp"
/>
<RelativeLayout
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:background="#color/primary">
<ImageButton
android:id="#+id/show_list_actualites"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:src="#drawable/ic_fleche_bas"
android:adjustViewBounds="true"
android:layout_toLeftOf="#+id/loupe"
android:layout_marginLeft="20dp"
android:layout_marginRight="15dp"
android:layout_centerVertical="true"
android:padding="15dp"
android:background="#color/primaryDark"
/>
<!--android:background="#android:color/transparent"-->
<ImageView
android:id="#+id/loupe"
android:layout_width="wrap_content"
android:layout_height="12dip"
android:src="#drawable/ic_rech"
android:rotation="270"
android:adjustViewBounds="true"
android:layout_centerVertical="true"
android:layout_alignParentRight="true"
android:layout_marginRight="20dp"
android:background="#color/primaryDark"
/>
</RelativeLayout>
</android.support.v7.widget.Toolbar>
</RelativeLayout>
<RelativeLayout
android:id="#+id/content_frame"
android:layout_width="match_parent"
android:layout_height="match_parent">
<FrameLayout
android:id="#+id/content_fragment"
android:layout_width="match_parent"
android:layout_height="match_parent"/>
<LinearLayout
android:id="#+id/slide_news_list"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical"
android:visibility="gone">
<ListView
android:id="#+id/list_slider_news_menu"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="#color/action_bar_background"
android:text="Item 1"/>
<Button
android:id="#+id/close_news_slide"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="#color/grey_tranparent"/>
</LinearLayout>
</RelativeLayout>
</LinearLayout>
<ListView
android:id="#+id/left_drawer"
android:background="#android:color/white"
android:layout_width="305dp"
android:layout_height="match_parent"
android:layout_gravity="start"/>
</android.support.v4.widget.DrawerLayout>
styles.xml
<resources xmlns:android="http://schemas.android.com/apk/res/android">
<style name="Theme.AppCompat.Light.NoActionBar" parent="#style/Theme.AppCompat.Light">
<item name="android:windowNoTitle">true</item>
<item name="windowActionBar">false</item>
</style>
<style name="AppTheme.Base" parent="Theme.AppCompat.Light.NoActionBar">
<item name="colorPrimary">#color/primary</item>
<item name="colorPrimaryDark">#color/primaryDark</item>
</style>
<style name="AppTheme" parent="AppTheme.Base">
</style>
<style name="ToolbarTheme" parent="Theme.AppCompat">
<item name="android:windowNoTitle">true</item>
<item name="android:textColorPrimary">#color/action_bar_text</item>
<item name="actionMenuTextColor">#color/action_bar_text</item>
<item name="android:textColorSecondary">#color/action_bar_text</item>
<item name="android:layout_gravity">center_horizontal</item>
</style>
</resources>
Centering the Text in the Toolbar is against Android design standards. I think this is why you are having issues accomplishing this. I would not try to adjust your text alignment, which will insure your app fits within the Android ecosystem.
Check this link for details on Toolbar design standards: http://www.google.com/design/spec/layout/structure.html#structure-toolbars
I am not answering how you WOULD do what you are asking, but suggesting that you DON'T do it in the first place (use the standard format, and this will be easier for you).
try this code...
Toolbar's parent is viewgroup. So u cannot design like that. I used FrameLayout to place items.
<FrameLayout
android:layout_width="match_parent"
android:layout_height="wrap_content">
<RelativeLayout
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:background="#color/primary">
<ImageButton
android:id="#+id/show_list_actualites"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:src="#drawable/ic_launcher"
android:adjustViewBounds="true"
android:layout_toLeftOf="#+id/loupe"
android:layout_marginLeft="20dp"
android:layout_marginRight="15dp"
android:layout_centerVertical="true"
android:padding="15dp"
android:background="#color/primaryDark"
/>
<!-- android:background="#android:color/transparent"-->
<ImageView
android:id="#+id/loupe"
android:layout_width="wrap_content"
android:layout_height="12dip"
android:src="#drawable/ic_launcher"
android:rotation="270"
android:adjustViewBounds="true"
android:layout_centerVertical="true"
android:layout_alignParentRight="true"
android:layout_marginRight="20dp"
android:background="#color/primaryDark"
/>
</RelativeLayout>
<TextView
android:id="#+id/toolbar_title"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerVertical="true"
android:layout_gravity="center"
android:background="#color/primaryDark"
android:textSize="20dp"
android:text="Title"
/>
</FrameLayout>