I'm trying to do a sliding menu for my app which is activated when pushing a button but I don't have so big idea about how to achieve that. At the moment, I'm following this tutorial.
My problem at the moment is that I'm trying to merge the DrawerLayout with my Activity because I wanna launch the slide menu over the Activity that I already have. Here is the merged XML:
<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:paddingLeft="#dimen/activity_horizontal_margin"
android:paddingRight="#dimen/activity_horizontal_margin"
android:paddingTop="#dimen/activity_vertical_margin"
android:paddingBottom="#dimen/activity_vertical_margin"
android:id="#+id/pantallaPrincipalGenerarBackgroundView">
<ScrollView
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:id="#+id/scrollView"
android:fillViewport="true"
android:layout_alignParentBottom="true"
android:layout_alignParentTop="true">
<LinearLayout
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:orientation="vertical"
android:layout_alignParentBottom="true"
android:layout_alignParentRight="true"
android:layout_alignParentEnd="true">
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textAppearance="?android:attr/textAppearanceLarge"
android:text="Seleccione dificultad"
android:id="#+id/textView"
android:layout_alignParentLeft="true"
android:layout_alignParentRight="true"
android:gravity="center_horizontal"
android:layout_gravity="center_horizontal" />
<RadioGroup
android:orientation="horizontal"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_below="#+id/textView"
android:gravity="top|center"
android:id="#+id/linearLayout"
android:layout_gravity="bottom">
<RadioButton
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Facil"
android:id="#+id/FacilButton"
android:layout_marginLeft="10dp"
android:layout_marginRight="10dp"
android:layout_marginTop="20dp" />
<RadioButton
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Medio"
android:id="#+id/MedioButton2"
android:layout_marginRight="10dp"
android:layout_marginLeft="10dp"
android:layout_marginTop="20dp" />
<RadioButton
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="DifĂcil"
android:id="#+id/DifĂcilButton"
android:layout_marginLeft="10dp"
android:layout_marginRight="10dp"
android:layout_marginTop="20dp" />
</RadioGroup>
<LinearLayout
android:orientation="horizontal"
android:layout_width="fill_parent"
android:layout_height="wrap_content">
<LinearLayout
android:orientation="horizontal"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_below="#+id/linearLayout"
android:id="#+id/linearLayout2"
android:layout_marginTop="10dp"
android:layout_marginBottom="10dp"
android:weightSum="1">
<EditText
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:inputType="number"
android:id="#+id/longitudText"
android:hint="Introduce longitud"
android:singleLine="true"
android:layout_weight="0.45" />
<Button
android:layout_marginTop="0dp"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Generar"
android:id="#+id/Generarbutton"
android:layout_marginLeft="20dp" />
</LinearLayout>
</LinearLayout>
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textAppearance="?android:attr/textAppearanceLarge"
android:text="Pass"
android:id="#+id/contraseniaActual"
android:layout_below="#+id/linearLayout2"
android:layout_centerHorizontal="true"
android:layout_margin="5dp"
android:textColor="#ff1024ff"
android:textSize="15dp"
android:singleLine="true"
android:shadowColor="#ff69ff00"
android:layout_gravity="center_horizontal" />
<LinearLayout
android:orientation="vertical"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_gravity="center_horizontal">
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textAppearance="?android:attr/textAppearanceLarge"
android:text="Usuario"
android:id="#+id/textView2"
android:layout_below="#+id/passwordText"
android:layout_centerHorizontal="true"
android:layout_gravity="center_horizontal" />
<EditText
android:layout_width="229dp"
android:layout_height="wrap_content"
android:id="#+id/nombreUsuarioTextView"
android:layout_below="#+id/textView2"
android:layout_centerHorizontal="true"
android:layout_alignParentLeft="true"
android:layout_alignParentRight="true"
android:hint="Introduzca usuario"
android:layout_margin="7dp"
android:singleLine="true"
android:layout_gravity="center_horizontal" />
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textAppearance="?android:attr/textAppearanceLarge"
android:text="Seleccione el servicio"
android:id="#+id/textView3"
android:layout_below="#+id/newUserText"
android:layout_centerHorizontal="true"
android:layout_gravity="center_horizontal" />
<LinearLayout
android:orientation="horizontal"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:layout_gravity="center_horizontal">
<Button
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Servicios"
android:drawableLeft="#drawable/flechaizquierda"
android:id="#+id/abrirListaServiciosButton"
android:layout_above="#+id/guardarButton"
android:layout_alignParentLeft="true"
android:layout_alignParentStart="true" />
<LinearLayout
android:orientation="horizontal"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:layout_toEndOf="#+id/abrirListaServiciosButton"
android:gravity="center"
android:weightSum="1"
android:layout_alignTop="#+id/abrirListaServiciosButton"
android:layout_toRightOf="#+id/abrirListaServiciosButton"
android:layout_marginTop="0dp"
android:layout_alignRight="#+id/newUserText"
android:layout_alignEnd="#+id/newUserText">
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textAppearance="?android:attr/textAppearanceMedium"
android:text="SERVICIOTEST0"
android:id="#+id/textoMostrarServicioSeleccionado"
android:textColor="#ff000000"
android:maxLength="13"
android:maxLines="1" />
<ImageView
android:layout_width="80dp"
android:layout_height="match_parent"
android:id="#+id/imageMostrarServicioSeleccionado"
android:layout_gravity="right" />
</LinearLayout>
</LinearLayout>
</LinearLayout>
<LinearLayout
android:orientation="horizontal"
android:layout_width="match_parent"
android:layout_height="wrap_content">
<Button
android:layout_width="200dp"
android:layout_height="100dp"
android:text="Guardar"
android:id="#+id/guardarButton"
android:layout_alignParentBottom="true"
android:layout_alignParentLeft="true"
android:layout_alignParentStart="true" />
<LinearLayout
android:orientation="vertical"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_toEndOf="#+id/guardarButton"
android:id="#+id/linearLayout5"
android:layout_alignParentBottom="true"
android:layout_alignParentRight="true"
android:layout_alignParentEnd="true"
android:layout_gravity="center_horizontal">
<Button
android:layout_width="100dp"
android:layout_height="wrap_content"
android:text="Salir"
android:id="#+id/salirycerrarPantallaGenerarButton"
android:layout_alignBottom="#+id/guardarButton"
android:layout_alignLeft="#+id/goToSegundabutton"
android:layout_alignStart="#+id/goToSegundabutton"
android:layout_margin="1dp"
android:layout_gravity="center_horizontal" />
<Button
android:layout_width="100dp"
android:layout_height="wrap_content"
android:text="Cancelar"
android:id="#+id/goToSegundabutton"
android:layout_alignTop="#+id/guardarButton"
android:layout_centerHorizontal="true"
android:layout_marginBottom="0dp"
android:layout_gravity="center_horizontal" />
</LinearLayout>
</LinearLayout>
</LinearLayout>
</ScrollView>
<!-- Slide menu code, supuestamente. -->
<android.support.v4.widget.DrawerLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:id="#+id/drawer_layout"
android:layout_width="match_parent"
android:layout_height="match_parent">
<!-- Framelayout to display Fragments -->
<FrameLayout
android:id="#+id/frame_container"
android:layout_width="match_parent"
android:layout_height="match_parent" />
<!-- Listview to display slider menu -->
<ListView
android:id="#+id/list_slidermenu"
android:layout_width="240dp"
android:layout_height="match_parent"
android:layout_gravity="start"
android:choiceMode="singleChoice"
android:divider="#color/list_divider"
android:dividerHeight="1dp"
android:listSelector="#drawable/list_selector"
android:background="#color/list_background"/>
</android.support.v4.widget.DrawerLayout>
</RelativeLayout>
As you can see at the bottom of the file, I just added out of all my activity but inside the parent RelativeLayout their DrawerLayout. Now the problem I'm getting is when addressing it from the java code.
When I do mDrawerLayout = (DrawerLayout) findViewById(R.id.drawer_layout); it says that they are inconvertable types, cannot cast from android.view.View to android.support.v4.widget.DrawerLayout.
Any idea how could I do that?? I don't care about changing my code, but I want this menu to come over my activity, not over an empty one. I just didn't find any good tutorial or video tutorial over the internet.
Thank you so much :)
I suggest you to take a look at Google IO source code. You have there pretty good example of using DrawerLayout.
And it's easy.
First of all.
It's good to have DrawerLayout on top.
For example. MapActivity - activity_map.xml
<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:context=".ui.phone.MapActivity">
<com.google.samples.apps.iosched.ui.widget.ScrimInsetsFrameLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:id="#+id/capture_insets_frame_layout"
app:insetForeground="#color/translucent_statusbar_background"
android:fitsSystemWindows="true">
<!-- Main layout -->
<FrameLayout
android:id="#+id/fragment_container_map"
android:layout_width="match_parent"
android:layout_height="match_parent" />
<include layout="#layout/toolbar_actionbar_translucent" />
<android.support.v7.widget.CardView
android:id="#+id/fragment_container_popup"
android:visibility="gone"
android:clickable="true"
android:layout_width="match_parent"
android:layout_height="match_parent" />
</com.google.samples.apps.iosched.ui.widget.ScrimInsetsFrameLayout>
<!-- Nav drawer -->
<include layout="#layout/navdrawer" />
</android.support.v4.widget.DrawerLayout>
And as you can see you have NavDrawer include at the end.
nadrawer.xml
<LinearLayout android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical">
<FrameLayout
android:id="#+id/chosen_account_view"
android:layout_width="match_parent"
android:layout_height="#dimen/navdrawer_chosen_account_height"
android:foreground="?photoItemForeground">
<ImageView android:layout_width="match_parent"
android:layout_height="match_parent"
android:scaleType="centerCrop"
android:src="#drawable/default_cover"
android:tint="#color/session_photo_scrim"
android:id="#+id/profile_cover_image" />
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:paddingLeft="#dimen/keyline_1"
android:paddingRight="#dimen/keyline_1"
android:paddingTop="#dimen/keyline_1"
android:id="#+id/chosen_account_content_view">
<com.google.samples.apps.iosched.ui.widget.BezelImageView
android:id="#+id/profile_image"
android:layout_width="#dimen/navdrawer_profile_image_size"
android:layout_height="#dimen/navdrawer_profile_image_size"
android:src="#drawable/person_image_empty"
android:scaleType="centerCrop"
app:maskDrawable="#drawable/circle_mask" />
<ImageView
android:id="#+id/expand_account_box_indicator"
android:layout_height="wrap_content"
android:layout_width="wrap_content"
android:visibility="gone"
android:layout_marginLeft="16dp"
android:paddingBottom="16dp"
android:layout_alignParentEnd="true"
android:layout_alignParentBottom="true"
android:scaleType="center"
android:src="#drawable/ic_drawer_accounts_expand" />
<TextView
android:id="#+id/profile_email_text"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_alignLeft="#id/profile_image"
android:layout_toLeftOf="#id/expand_account_box_indicator"
android:layout_alignParentBottom="true"
android:paddingBottom="16dp"
android:textSize="#dimen/text_size_medium"
android:textColor="#color/body_text_2_inverse"
android:maxLines="1"
android:singleLine="true"
android:ellipsize="end" />
<TextView
android:id="#+id/profile_name_text"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_above="#id/profile_email_text"
android:layout_alignLeft="#id/profile_image"
android:layout_toLeftOf="#id/expand_account_box_indicator"
android:textSize="#dimen/text_size_large"
android:textColor="#color/body_text_1_inverse"
android:maxLines="1"
android:singleLine="true"
android:ellipsize="end" />
</RelativeLayout>
</FrameLayout>
<FrameLayout android:layout_width="match_parent"
android:layout_height="wrap_content">
<!-- Account items -->
<LinearLayout
android:id="#+id/account_list"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="8dp"
android:orientation="vertical"
android:visibility="invisible" />
<!-- Drawer items -->
<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" />
</FrameLayout>
</LinearLayout>
You'll find whole project here: https://github.com/google/iosched
Related
I have the following xml which is supposed to be something similar to the following
The activity shows mostly ok, but i cant get the two down buttons to get fixed to the bottom of the screen without messing the top views.
I've tried to use a FrameLayout with two RelativeLayouts, alignment_bottom, an empty view with weight 1 between components and even still havent being able to accomplish my goal. Any help will be really appreciated, thank you in advance.
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout android:layout_width="match_parent"
android:orientation="vertical"
android:layout_height="match_parent"
xmlns:android="http://schemas.android.com/apk/res/android">
<ScrollView android:layout_width="match_parent" android:layout_height="match_parent"
xmlns:android="http://schemas.android.com/apk/res/android">
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:id="#+id/RelativeLayout1">
<ImageView
android:id="#+id/group_info_image"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:scaleType="fitStart"
android:adjustViewBounds="true"
android:layout_alignParentTop="true"
/>
<TextView
android:id="#+id/description_text"
android:layout_below="#id/group_info_image"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:textColor="#color/mainColor"
android:textSize="20sp"
android:text="#string/descripcion"
android:layout_marginStart="10dp"
android:layout_marginTop="10dp"
android:fontFamily="sans-serif"
/>
<TextView
android:layout_below="#id/description_text"
android:gravity="start"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:id="#+id/group_info_description"
android:layout_marginTop="5dp"
android:layout_marginBottom="10dp"
android:layout_marginStart="10dp"
android:textSize="15sp"/>
<TextView
android:layout_below="#id/group_info_description"
android:scrollbars="vertical"
android:gravity="center"
android:textColor="#android:color/black"
android:layout_marginTop="10dp"
android:layout_marginStart="5dp"
android:layout_marginBottom="2dp"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:id="#+id/group_info_user_number"
android:textSize="15sp"
/>
<es.tretornesp.clickerchat.NonScrollableListView
android:layout_below="#id/group_info_user_number"
android:id="#+id/group_info_user_list"
android:layout_height="match_parent"
android:divider="#drawable/list_divider"
android:dividerHeight="1px"
android:layout_width="match_parent"/>
</RelativeLayout>
</ScrollView>
<LinearLayout
android:orientation="vertical"
android:layout_width="match_parent"
android:layout_height="wrap_content">
<Button
android:id="#+id/delete_group"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="#string/borrar_grupo"
android:background="#color/mainColor" />
<View
android:id="#+id/divisor"
android:layout_width="match_parent"
android:layout_height="1dp"
android:background="#color/grey"/>
<Button
android:id="#+id/exit_group"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:textColor="#android:color/white"
android:text="#string/salir"
android:background="#color/mainColor"
/>
</LinearLayout>
</LinearLayout>
Change your layout file as below,
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
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/exit_group">
<RelativeLayout
android:id="#+id/RelativeLayout1"
android:layout_width="match_parent"
android:layout_height="wrap_content">
<ImageView
android:id="#+id/group_info_image"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_alignParentTop="true"
android:adjustViewBounds="true"
android:scaleType="fitStart" />
<TextView
android:id="#+id/description_text"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_below="#id/group_info_image"
android:layout_marginStart="10dp"
android:layout_marginTop="10dp"
android:fontFamily="sans-serif"
android:text="#string/descripcion"
android:textColor="#color/mainColor"
android:textSize="20sp" />
<TextView
android:id="#+id/group_info_description"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_below="#id/description_text"
android:layout_marginBottom="10dp"
android:layout_marginStart="10dp"
android:layout_marginTop="5dp"
android:gravity="start"
android:textSize="15sp" />
<TextView
android:id="#+id/group_info_user_number"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_below="#id/group_info_description"
android:layout_marginBottom="2dp"
android:layout_marginStart="5dp"
android:layout_marginTop="10dp"
android:gravity="center"
android:scrollbars="vertical"
android:textColor="#android:color/black"
android:textSize="15sp" />
<es.tretornesp.clickerchat.NonScrollableListView
android:id="#+id/group_info_user_list"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_below="#id/group_info_user_number"
android:divider="#drawable/list_divider"
android:dividerHeight="1px" />
<Button
android:id="#+id/delete_group"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_below="#+id/group_info_user_list"
android:background="#color/mainColor"
android:text="#string/borrar_grupo" />
<View
android:id="#+id/divisor"
android:layout_width="match_parent"
android:layout_height="1dp"
android:layout_below="#id/delete_group"
android:background="#color/grey" />
</RelativeLayout>
</ScrollView>
<Button
android:id="#+id/exit_group"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_alignParentBottom="true"
android:background="#color/mainColor"
android:text="#string/salir"
android:textColor="#android:color/white" />
</RelativeLayout>
Use Coordinator Layout as a parent layout. like 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:card_view="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:fitsSystemWindows="false">
// your code
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_gravity="bottom"
android:orientation="horizontal">
<TextView
android:id="#+id/txt_contact_laksha_group"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="demo"
/>
</LinearLayout>
</android.support.design.widget.CoordinatorLayout>
What i want to accomplish is to create rating section like Google Play Store, i managed to display all the stars and review(for user to comment) but whenever the user type on it, the layout height of the RelativeLayout on my activity doesn't wrap the layout of the fragment within a fragment. I tried changing the height in any means, but still nothing solve the problem. The thing is when i make my TabLayout visible, it follows the height, but not my custom ViewPager.
I do not know whether i did it right or wrong or entirely impossible, please show me the right way. Thank you.
activity_view_item.xml
<?xml version="1.0" encoding="utf-8"?>
<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.hybridelements.recyclerview.ViewItem">
<ScrollView
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_alignParentTop="true"
android:layout_alignParentStart="true"
android:layout_alignParentLeft="true">
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="wrap_content">
<ImageView
android:id="#+id/singleImageView"
android:layout_width="150dp"
android:layout_height="150dp"
android:layout_centerHorizontal="true"
android:layout_marginTop="29dp"
app:srcCompat="#drawable/android" />
<TextView
android:id="#+id/lblTitle"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="#string/lblTitle"
android:layout_alignBottom="#+id/itemName"
android:textSize="16sp"
android:layout_marginLeft="25dp"
android:textStyle="bold"/>
<TextView
android:id="#+id/itemName"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="16dp"
android:text="#string/itemName"
android:textSize="16sp"
android:layout_below="#+id/singleImageView"
android:layout_alignStart="#+id/singleImageView"/>
<TextView
android:id="#+id/lblCategory"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="#string/lblCategory"
android:layout_alignTop="#+id/itemCategory"
android:layout_alignStart="#+id/lblTitle"
android:layout_marginRight="30dp"
android:textSize="16sp"
android:textStyle="bold"/>
<TextView
android:id="#+id/itemCategory"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="#string/itemCategory"
android:textSize="16sp"
android:layout_below="#+id/itemName"
android:layout_alignStart="#+id/singleImageView"
android:layout_marginTop="14dp" />
<TextView
android:id="#+id/lblRating"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignStart="#+id/lblCategory"
android:layout_below="#+id/lblCategory"
android:layout_marginTop="13dp"
android:text="#string/lblRating"
android:textSize="16sp"
android:textStyle="bold" />
<TextView
android:id="#+id/itemRating"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignBottom="#+id/lblRating"
android:layout_alignStart="#+id/singleImageView"
android:text="#string/itemRating"
android:textSize="16sp" />
<ImageView
android:id="#+id/imageRating"
android:layout_width="17dp"
android:layout_height="17dp"
android:layout_alignBottom="#+id/itemRating"
android:layout_alignTop="#+id/itemRating"
android:layout_gravity="center"
android:layout_toEndOf="#+id/itemRating"
android:layout_marginLeft="5dp"
app:srcCompat="#drawable/star" />
<TextView
android:id="#+id/lblDesc"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="13dp"
android:text="#string/lblDesc"
android:textSize="16sp"
android:textStyle="bold"
android:layout_alignStart="#+id/itemDesc"
android:layout_below="#+id/itemRating"/>
<TextView
android:id="#+id/itemDesc"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_below="#+id/lblDesc"
android:layout_centerHorizontal="true"
android:layout_marginLeft="25dp"
android:layout_marginRight="25dp"
android:layout_marginTop="13dp"
android:text="#string/itemDesc"
android:textSize="16sp" />
<RelativeLayout
android:id="#+id/ratingSection"
android:layout_width="match_parent"
android:layout_height="130dp"
android:layout_marginTop="13dp"
android:layout_below="#+id/itemDesc"
android:background="#color/ratingSection">
<!-- Get section from fragment -->
</RelativeLayout>
<RelativeLayout
android:id="#+id/subTab"
android:layout_width="match_parent"
android:layout_height="511.84dp"
android:layout_marginTop="13dp"
android:layout_below="#+id/ratingSection">
<!-- Get section from fragment -->
</RelativeLayout>
</RelativeLayout>
</ScrollView>
fragment_sub_section_rating.xml
<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="wrap_content"
tools:context="com.hybridelements.openchef.fragment_activities.fragment_subs.SubSectionFragment_ReviewAndInstructions">
<RelativeLayout
android:id="#+id/main_layout"
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="wrap_content"
tools:context=".MainActivity">
<android.support.design.widget.TabLayout
android:id="#+id/tab_layout"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="?attr/colorPrimary"
android:elevation="6dp"
android:minHeight="?attr/actionBarSize"
android:theme="#style/ThemeOverlay.AppCompat.Dark.ActionBar"
android:visibility="gone"/>
<com.hybridelements.openchef.fragment_activities.fragment_subs.CustomSubViewPager
android:id="#+id/pager"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_below="#id/tab_layout"/>
<com.pixelcan.inkpageindicator.InkPageIndicator
android:id="#+id/fragRating_dotIndicator"
android:layout_width="match_parent"
android:layout_height="wrap_content"
app:dotDiameter="8dp"
app:dotGap="8dp"
app:animationDuration="320"
app:pageIndicatorColor="#android:color/darker_gray"
app:currentPageIndicatorColor="#android:color/black"
android:layout_alignBottom="#+id/pager"
android:layout_marginBottom="20dp"
android:visibility="gone" />
</RelativeLayout>
fragment_rating_review.xml
<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="wrap_content"
tools:context="com.hybridelements.openchef.fragment_activities.fragment_subs.RatingFragment_Star">
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="wrap_content">
<TextView
android:id="#+id/ratingReview"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="#string/fragmentRating_reviewHeader"
android:textAlignment="center"
android:layout_marginTop="13dp"
android:textSize="16dp"
android:textStyle="bold" />
<RelativeLayout
android:id="#+id/ratingStar"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_below="#+id/ratingReview"
android:gravity="center_horizontal">
<EditText
android:id="#+id/userRateReview"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginLeft="25dp"
android:layout_marginRight="25dp"/>
</RelativeLayout>
<Button
android:id="#+id/ratingBtnSubmit"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="#+id/ratingStar"
android:layout_alignParentEnd="true"
android:text="#string/ratingFrag_BtnSubmit"
style="#style/Widget.AppCompat.Button.Borderless"
android:enabled="false"/>
</RelativeLayout>
The RelativeLayout with id "ratingSection" in ratingSactivity_view_item.xml should follow the height of FrameLayout in fragment_rating_review.xml
This shouldn't happen.
This is before any typing (seems normal)
After typing, the submit button going off the screen
Try with this layout.
<FrameLayout
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="wrap_content">
<LinearLayout
android:layout_width="match_parent"
android:orientation="vertical"
android:layout_height="wrap_content">
<TextView
android:id="#+id/ratingReview"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="fragmentRating_reviewHeader"
android:textAlignment="center"
android:layout_marginTop="13dp"
android:textSize="16dp"
android:textStyle="bold" />
<RelativeLayout
android:id="#+id/ratingStar"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_above="#+id/ratingStar"
android:layout_below="#+id/ratingReview"
android:gravity="center_horizontal">
<EditText
android:id="#+id/userRateReview"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginLeft="25dp"
android:layout_marginRight="25dp"/>
</RelativeLayout>
<Button
android:id="#+id/ratingBtnSubmit"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="right"
android:layout_alignParentRight="true"
android:layout_below="#+id/ratingStar"
android:text="ratingFrag_BtnSubmit"
style="#style/Widget.AppCompat.Button.Borderless"
android:enabled="false"/>
</LinearLayout>
</FrameLayout>
I am using this lib and when I open the menu it makes the shadow like i am using blur in the background. And loading the songs from the memory(in the main thread). The shadow appears some times. . I dont know why it is happening .In the following layout the background is transparent but the following menu is strong color. what can i do to fix this .I made the images in multiple size also ex hdpi , xhdpi etc. what is the mistake i am doing . The shadow appears when I open and close the menu.
the xml code
<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"
xmlns:app="http://schemas.android.com/apk/res-auto"
tools:context="beatbox.Fragment.Songs">
<!-- TODO: Update blank fragment layout -->
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="match_parent">
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_marginTop="110dp">
<com.github.florent37.arclayout.ArcLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:rotation="180"
app:arc_cropDirection="cropInside"
app:arc_height="40dp"
app:theme="#style/Theme.AppCompat.Light">
<View
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="#7c2c3940" />
</com.github.florent37.arclayout.ArcLayout>
</RelativeLayout>
<ScrollView
android:layout_width="match_parent"
android:layout_height="match_parent"
android:fillViewport="true"
android:layout_gravity="fill_vertical"
>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical">
<ListView
android:id="#+id/song_listview"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_marginTop="175dp"
android:divider="#null"
android:cacheColorHint="#00000000"
android:fadingEdgeLength="48dp"
android:requiresFadingEdge="vertical"
android:fadingEdge="horizontal"
android:overScrollMode="never" />
</LinearLayout>
</ScrollView>
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="120dp">
<ImageButton
android:layout_width="70dp"
android:layout_height="70dp"
android:layout_marginRight="21dp"
android:layout_marginEnd="21dp"
android:id="#+id/imageButton"
android:background="#00000000"
android:scaleType="fitXY"
android:layout_alignParentTop="true"
android:layout_alignParentRight="true"
android:layout_alignParentEnd="true"
android:layout_marginTop="30dp" />
<TextView
android:id="#+id/textView16"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignLeft="#+id/textView15"
android:layout_alignStart="#+id/textView15"
android:layout_below="#+id/textView15"
android:maxLines="1"
android:layout_marginEnd="140dp"
android:layout_marginRight="140dp"
android:singleLine="true"
android:textSize="12sp"
android:textStyle="bold" />
<TextView
android:id="#+id/textView15"
android:layout_height="wrap_content"
android:layout_alignParentLeft="true"
android:layout_width="wrap_content"
android:layout_alignParentStart="true"
android:layout_alignParentTop="true"
android:layout_marginEnd="120dp"
android:layout_marginLeft="24dp"
android:layout_marginRight="120dp"
android:layout_marginStart="24dp"
android:layout_marginTop="31dp"
android:maxLines="1"
android:singleLine="true"
android:text="#string/total_songs"
android:textSize="26sp" />
</RelativeLayout>
</RelativeLayout>
<FrameLayout
android:id="#+id/edittextview"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:visibility="invisible">
<com.github.stephenvinouze.shapeview.shapes.HalfCircleEdgeShapeView
android:layout_width="match_parent"
android:layout_height="66dp"
android:layout_marginLeft="16.5dp"
android:layout_marginRight="16.5dp"
android:layout_marginTop="105dp"
android:elevation="0dp"
app:shapeColor="#color/colorAccent">
<ImageButton
android:id="#+id/close_edittext"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentLeft="true"
android:layout_alignParentStart="true"
android:layout_centerInParent="true"
android:layout_marginLeft="17dp"
android:layout_marginStart="17dp"
android:background="#00000000"
app:srcCompat="#drawable/ic_clear_white_48dp"
/>
<EditText
android:id="#+id/editText"
style="#android:style/Theme.Holo"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_centerVertical="true"
android:layout_marginEnd="20dp"
android:layout_marginRight="20dp"
android:layout_toEndOf="#+id/close_edittext"
android:layout_toRightOf="#+id/close_edittext"
android:hint="Search"
android:inputType="textPersonName"
android:paddingEnd="20dp"
android:paddingRight="20dp"
android:textSize="18sp"
tools:ignore="HardcodedText" />
</com.github.stephenvinouze.shapeview.shapes.HalfCircleEdgeShapeView>
</FrameLayout>
<FrameLayout
android:id="#+id/menu"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_alignParentLeft="true"
android:layout_alignParentStart="true"
android:layout_alignParentTop="true">
<com.srx.widget.TabBarView
android:id="#+id/tabBarView"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="105dp"
android:elevation="0dp" >
</com.srx.widget.TabBarView>
</FrameLayout>
I want to implement my app with DrawerToggle and ActionBar (support v4). I need the toggle overlay actionBar as like as Google Play Store in this http://prntscr.com/90nl4n.
How can i do? Every suggestion will be highly appreciated. Thanks in advance
Here is my layout:
<RelativeLayout
android:id="#+id/layoutRoot"
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:orientation="vertical">
<TextView
android:id="#+id/tvTabDivider"
style="#style/divider"/>
<android.support.v4.widget.DrawerLayout
android:id="#+id/slidingMenu"
android:layout_width="match_parent"
android:layout_height="match_parent">
<FrameLayout
android:id="#+id/realtabcontent"
android:layout_width="match_parent"
android:layout_height="match_parent"/>
<!-- Sliding menu -->
<ScrollView
android:id="#+id/sv_slidingMenu"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_gravity="start"
android:background="#mipmap/bg_left_menu">
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="#drawable/bg_blur_left_menu">
<RelativeLayout
android:id="#+id/v_account"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentTop="true"
android:layout_centerHorizontal="true"
android:paddingBottom="10dp"
android:paddingTop="10dp">
<ImageView
android:id="#+id/iv_avatar"
style="#style/imageview_normal"
android:layout_width="#dimen/height_avatar_menu"
android:layout_height="#dimen/height_avatar_menu"
android:layout_centerVertical="true"
android:layout_gravity="center"
android:padding="8dp"
android:scaleType="centerCrop"
android:src="#mipmap/img_logo"
app:border="true"
app:border_color="#color/white"
app:border_width="1dp"/>
<LinearLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerVertical="true"
android:layout_marginLeft="10dp"
android:layout_toRightOf="#+id/iv_avatar"
android:orientation="vertical">
<TextView
android:id="#+id/tv_login"
style="#style/text_normal.bold.white"
android:layout_marginRight="10dp"
android:layout_marginTop="10dp"
android:background="#drawable/bg_circle_line_white"
android:gravity="left"
android:text="#string/login"/>
<TextView
android:id="#+id/tv_account_info"
style="#style/text_normal.bold.white"
android:layout_marginRight="10dp"
android:layout_marginTop="10dp"
android:background="#drawable/bg_circle_line_white"
android:drawableLeft="#mipmap/ic_setting"
android:drawablePadding="8dp"
android:gravity="left"
android:text="#string/acccount_info"
android:visibility="gone"/>
</LinearLayout>
</RelativeLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_below="#+id/v_account"
android:orientation="vertical">
<TextView
android:id="#+id/tvSearch"
style="#style/styleTextInfo"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="#drawable/selector_menu_bg"
android:drawableLeft="#mipmap/ic_search_left_menu"
android:drawablePadding="5dp"
android:gravity="center_vertical"
android:text="#string/search"
android:textColor="#color/white"/>
<TextView
android:id="#+id/tvPostNews"
style="#style/styleTextInfo"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="#drawable/selector_menu_bg"
android:drawableLeft="#mipmap/ic_post_news_left_menu"
android:drawablePadding="5dp"
android:gravity="center_vertical"
android:text="#string/post_news_letter_fragment"
android:textColor="#color/white"/>
<TextView
android:id="#+id/tvSalon"
style="#style/styleTextInfo"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="#drawable/selector_menu_bg"
android:drawableLeft="#mipmap/ic_salon_left_menu"
android:drawablePadding="5dp"
android:gravity="center_vertical"
android:text="#string/salon"
android:textColor="#color/white"/>
</LinearLayout>
</RelativeLayout>
</ScrollView>
</android.support.v4.widget.DrawerLayout>
</RelativeLayout>
I am trying to add a vertical linear layout (having a title, image, menu title, listview and an icon at the bottom)to the navigation drawer. However the app crashes displaying
'java.lang.ClassCastException: android.widget.LinearLayout$LayoutParams cannot be cast to android.support.v4.widget.DrawerLayout$LayoutParams'
error. I am not sure if this is possible straight ways as I checked couple of links and the only close I got was this. Any help is appreciated.
Thanks in advance.
Here is my code.
<!-- The main context view -->
<FrameLayout
android:id="#+id/content_frame"
android:layout_width="match_parent"
android:layout_height="match_parent" />
<!-- The navigation drawer -->
<LinearLayout
android:layout_width="240dp"
android:layout_height="match_parent"
android:layout_gravity="start"
android:background="#fff"
android:gravity="bottom|center"
android:orientation="vertical"
android:paddingTop="30dp" >
<ListView
android:id="#+id/left_drawer"
android:choiceMode="singleChoice"
android:divider="#E8E8E8"
android:dividerHeight="1dp"
android:footerDividersEnabled="false"
android:headerDividersEnabled="false" />
<ImageView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:padding="10dp"
android:src="#drawable/footer_image" />
</LinearLayout>
Now the issue here is, xml is not allowing me to define width and height for the listview (Element is unknown) and I am also not able to run it as compiler says "You must supply a layout_width" attribute?? Please help.
My code with the scrollview.
<android.support.v4.widget.DrawerLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:id="#+id/drawer_layout"
android:layout_width="match_parent"
android:layout_height="match_parent" >
<!-- The main context view -->
<FrameLayout
android:id="#+id/content_frame"
android:layout_width="match_parent"
android:layout_height="match_parent" />
<!-- The navigation drawer -->
<ScrollView
android:id="#+id/leftRL"
android:layout_width="240dp"
android:layout_height="match_parent"
android:layout_gravity="start"
android:layout_marginBottom="5dp"
android:background="#fff" >
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical" >
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical"
android:paddingLeft="10dp"
android:paddingRight="10dp"
android:paddingTop="10dp" >
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:paddingBottom="3dp"
android:src="#drawable/ic_launcher"
android:text="Dummy"
android:textColor="#2E3192"
android:textStyle="bold" />
<View
android:layout_width="fill_parent"
android:layout_height="2dip"
android:background="#2E3192" />
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal"
android:paddingTop="2dp" >
<ImageView
android:layout_width="0dp"
android:layout_height="match_parent"
android:layout_weight="3"
android:background="#e8e8e8"
android:scaleType="fitXY"
android:src="#drawable/ic_launcher" />
<LinearLayout
android:layout_width="0dp"
android:layout_height="match_parent"
android:layout_weight="7"
android:gravity="center"
android:orientation="vertical"
android:padding="5dp" >
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="Dummy name"
android:textSize="15sp" />
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="dummyemail#imhot.com"
android:textSize="10sp" />
</LinearLayout>
</LinearLayout>
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="20dp"
android:paddingBottom="3dp"
android:src="#drawable/ic_launcher"
android:text="Dummy item"
android:textColor="#2E3192"
android:textStyle="bold" />
<View
android:layout_width="fill_parent"
android:layout_height="2dip"
android:background="#2E3192" />
</LinearLayout>
<ListView/>
<ImageView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:layout_marginTop="40dp"
android:padding="10dp"
android:src="#drawable/footer_image" />
</LinearLayout>
</ScrollView>
</android.support.v4.widget.DrawerLayout>
Your query is difficult to understand without code & stacktrace, but anyway..
Remember android.support.v4.widget.DrawerLayout can have 3 elements only (in exactly this order):
Your main page
Left Drawer
Right Drawer
Copy paste this example(only first two elements are there) & continue with your requirements
<android.support.v4.widget.DrawerLayout xmlns:android="http://schemas.android.com /apk/res/android"
android:id="#+id/drawer_layout"
android:layout_width="match_parent"
android:layout_height="match_parent" >
<!-- Your main screen -->
<RelativeLayout
android:layout_width="fill_parent"
android:layout_height="wrap_content" >
<RelativeLayout
android:id="#+id/topRL"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:background="#DE6D53"
android:orientation="horizontal" >
<ImageButton
android:id="#+id/left_drawer_button"
android:layout_width="30dp"
android:layout_height="30dp"
android:layout_alignParentLeft="true"
android:layout_centerVertical="true"
android:gravity="center_vertical"
android:onClick="onOpenLeftDrawer"
android:src="#drawable/ic_launcher" />
</RelativeLayout>
<FrameLayout
android:id="#+id/frame_to_be_replaced"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_below="#+id/topRL" />
</RelativeLayout>
<!-- left drawer -->
<RelativeLayout
android:id="#+id/whatYouWantInLeftDrawer"
android:layout_width="290dp"
android:layout_height="match_parent"
android:layout_gravity="start"
android:background="#android:color/black" >
<TextView
android:id="#+id/textView"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="title"
android:textColor="#android:color/white" />
<ListView
android:id="#+id/left_expandableListView"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_gravity="start" />
<TextView
android:layout_width="25dp"
android:layout_height="25dp"
android:layout_alignParentBottom="true"
android:textColor="#android:color/white"
android:text="bottom" />
</RelativeLayout>
</android.support.v4.widget.DrawerLayout>
Your Activity:
public class MainActivity extends Activity {
RelativeLayout leftRL;
RelativeLayout rightRL;
DrawerLayout drawerLayout;
#Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
// I'm removing the ActionBar.
requestWindowFeature(Window.FEATURE_NO_TITLE);
setContentView(R.layout.temp);
leftRL = (RelativeLayout)findViewById(R.id.whatYouWantInLeftDrawer);
drawerLayout = (DrawerLayout)findViewById(R.id.drawer_layout);
}
public void onOpenLeftDrawer(View view)
{
drawerLayout.openDrawer(leftRL);
}
}
do 2 things:
set gravity="START" to linearlayout not listview as LinearLayout is now drawer.
at the time of closing the drawer call drawer.close(Gravity.START); don't pass listView object here.
I got the solution using your answers, thanks :). Actually the issue was with the list view. I was getting the linear layout on the left drawer, however it wasnt displayed properly as I added a scroll View to my linear layout and I also had a list in the same view which displayed only the first item in the list leaving the entire screen space blank. I checked few links to get the answer but it didn't work. At the end, since the list data is known to me and it will not change dynamically I added RadioButtons, customized them and replaced the list.
My code looks like below now.
<android.support.v4.widget.DrawerLayout 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:background="#color/app_background" >
<!-- The main context view -->
<FrameLayout
android:id="#+id/fragment_holder"
android:layout_width="match_parent"
android:layout_height="match_parent" />
<!-- The navigation drawer -->
<ScrollView
android:id="#+id/leftDrawer"
android:layout_width="240dp"
android:layout_height="match_parent"
android:layout_gravity="start"
android:background="#fff" >
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical" >
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginLeft="10dp"
android:layout_marginRight="10dp"
android:layout_marginTop="10dp"
android:paddingBottom="3dp"
android:src="#drawable/ic_launcher"
android:text="#string/menu_account"
android:textColor="#color/nav_headingsColor"
android:textStyle="bold" />
<View
android:layout_width="fill_parent"
android:layout_height="2dip"
android:layout_marginLeft="10dp"
android:layout_marginRight="10dp"
android:background="#color/nav_headingsColor" />
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginLeft="10dp"
android:layout_marginRight="10dp"
android:orientation="horizontal" >
<ImageView
android:id="#+id/imgProfilePic"
android:layout_width="0dp"
android:layout_height="70dp"
android:layout_weight="3"
android:scaleType="fitXY"
android:src="#drawable/ic_launcher" />
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal" >
<ImageView
android:id="#+id/imgProfilePic"
android:layout_width="0dp"
android:layout_height="70dp"
android:layout_weight="3"
android:clickable="true"
android:contentDescription="#null"
android:scaleType="fitXY"
android:src="#drawable/ic_launcher" />
<LinearLayout
android:layout_width="0dp"
android:layout_height="match_parent"
android:layout_weight="7"
android:gravity="center"
android:orientation="vertical"
android:padding="5dp" >
<TextView
android:id="#+id/lblName"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="Christian Bale"
android:textColor="#color/nav_textColor"
android:textSize="18sp" />
<TextView
android:id="#+id/lblEmail"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="christianbale#imhot.com"
android:textColor="#color/nav_textColor"
android:textSize="10sp" />
</LinearLayout>
</LinearLayout>
</LinearLayout>
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginLeft="10dp"
android:layout_marginRight="10dp"
android:layout_marginTop="20dp"
android:paddingBottom="3dp"
android:src="#drawable/ic_launcher"
android:text="#string/menu_menu"
android:textColor="#color/nav_headingsColor"
android:textStyle="bold" />
<View
android:layout_width="fill_parent"
android:layout_height="2dip"
android:layout_marginLeft="10dp"
android:layout_marginRight="10dp"
android:background="#color/nav_headingsColor" />
<RadioGroup
android:id="#+id/radioGroup"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_marginRight="5dip"
android:layout_marginTop="2dip" >
<RadioButton
android:id="#+id/radioTopTen"
style="#style/RadioButton"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:drawableLeft="#drawable/ic_launcher"
android:paddingLeft="20dp"
android:text="#string/menu_topTen" />
<View
android:layout_width="fill_parent"
android:layout_height="1dip"
android:background="#color/nav_itemSep" />
<RadioButton
android:id="#+id/radioWish"
style="#style/RadioButton"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:drawableLeft="#drawable/ic_launcher"
android:paddingLeft="20dp"
android:text="#string/menu_wish" />
<View
android:layout_width="fill_parent"
android:layout_height="1dip"
android:background="#color/nav_itemSep" />
<RadioButton
android:id="#+id/radioGifts"
style="#style/RadioButton"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:drawableLeft="#drawable/ic_launcher"
android:paddingLeft="20dp"
android:text="#string/menu_gifts" />
<View
android:layout_width="fill_parent"
android:layout_height="1dip"
android:background="#color/nav_itemSep" />
<RadioButton
android:id="#+id/radioLibrary"
style="#style/RadioButton"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:drawableLeft="#drawable/ic_launcher"
android:paddingLeft="20dp"
android:text="#string/menu_library" />
<View
android:layout_width="fill_parent"
android:layout_height="1dip"
android:background="#color/nav_itemSep" />
<RadioButton
android:id="#+id/radioWhatsOn"
style="#style/RadioButton"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:drawableLeft="#drawable/ic_launcher"
android:paddingLeft="20dp"
android:text="#string/menu_whatsOn" />
<View
android:layout_width="fill_parent"
android:layout_height="1dip"
android:background="#color/nav_itemSep" />
<RadioButton
android:id="#+id/radioDownload"
style="#style/RadioButton"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:drawableLeft="#drawable/ic_launcher"
android:paddingLeft="20dp"
android:text="#string/menu_download" />
</RadioGroup>
<ImageView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:layout_marginTop="40dp"
android:padding="10dp"
android:src="#drawable/footer_image" />
</LinearLayout>
</ScrollView>
I know this might not be the best possibility but at least its working for me. If any one has a better solution, then please let me know.
This error is coming because of wrong import. Add a proper import for Layout params.
This import "android.widget.LinearLayout.LayoutParams" is getting mixed with Drawerlayout library declaration of LayoutParams ie "android.support.v4.widget.DrawerLayout$LayoutParams" resulting in ClassCast excption.
Try doing this,
In function selectItem,
change mDrawerLayout.closeDrawer(mDrawerList); to
mDrawerLayout.closeDrawer(mDrawerLinear);
Should work perfectly fine.
Because, the reference should now be your linearLayout, its no longer the listview that you are closing or opening.