Why my edittext layout and keyboard overlaps? - android

When I click edittext my layout stays under keyboard. It overlaps. I would like to move keyboard up when I click the edittext. Could you please help me with this problem ?
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout android:id="#+id/rootLayout"
xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="#android:color/white">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="#dimen/footer_height"
android:layout_alignParentTop="true"
android:background="#color/colorPrimary"
android:elevation="1dp"
android:orientation="horizontal">
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="match_parent">
<Button
android:id="#+id/chat_back_button"
style="#style/Base.Widget.AppCompat.Button.Borderless"
android:layout_width="80dp"
android:layout_height="40dp"
android:layout_centerVertical="true"
android:background="#drawable/image_back"/>
<TextView
android:id="#+id/chat_Header_textView"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerInParent="true"
android:text="#string/str_chat"
android:textColor="#android:color/white"
android:textSize="#dimen/activity_list_header_size"/>
</RelativeLayout>
</LinearLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_marginBottom="50dp"
android:layout_marginTop="54dp">
<ListView
android:id="#+id/chat_list"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="#android:color/white"
android:divider="#null"
android:dividerHeight="0dp"
android:transcriptMode="alwaysScroll"></ListView>
</LinearLayout>
<LinearLayout
android:id="#+id/chat_edit_layout"
android:layout_width="match_parent"
android:layout_height="50dp"
android:background="#color/colorPrimaryDark"
android:orientation="vertical"
android:padding="0.5dp"
android:layout_above="#+id/chat_footer_layout"
android:layout_centerHorizontal="true">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="#android:color/white"
android:orientation="horizontal">
<EditText
android:id="#+id/chat_edit"
android:layout_width="0dp"
android:layout_height="match_parent"
android:layout_weight="0.8"
android:background="#android:color/white"
android:gravity="start|center_vertical"
android:hint="#string/mesaj_yaz"
android:padding="2dp"/>
<ImageView
android:id="#+id/chat_send"
android:layout_width="0dp"
android:layout_height="match_parent"
android:layout_weight="0.2"
android:onClick="sendMessage"
android:src="#drawable/chat_icon"
android:visibility="gone"/>
<TextView
android:id="#+id/chat_text"
android:layout_width="0dp"
android:layout_height="match_parent"
android:layout_weight="0.3"
android:background="#color/colorPrimaryDark"
android:gravity="center"
android:onClick="sendMessage"
android:text="#string/gonder"
android:textColor="#android:color/white"
android:textSize="#dimen/activity_list_header_size"/>
</LinearLayout>
</LinearLayout>
<RelativeLayout
android:id="#+id/chat_footer_layout"
android:layout_width="match_parent"
android:layout_height="#dimen/footer_height"
android:layout_alignParentBottom="true"
>
<!--android:elevation="1dp"-->
<ImageView
android:id="#+id/chat_footer"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:scaleType="fitXY"/>
</RelativeLayout>
I added
getWindow().setSoftInputMode(WindowManager.LayoutParams.SOFT_INPUT_ADJUST_RESIZE); in onCreate() method. Also I added android:windowSoftInputMode="adjustResize" to activity in Manifest.xml. But still doesn't work.

try scrollView as parent layout and use "adjustPan" in your manifest
android:id="#+id/main_parent"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:fillViewport="true"

Related

How to fix the toolbar to the top in activity with the 'adjustpan' option?

I made the Layout as follows.
<?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"
android:orientation="vertical">
<android.support.v7.widget.Toolbar
android:id="#+id/toolbar"
android:layout_width="match_parent"
android:layout_height="?attr/actionBarSize"
android:layout_below="#+id/layout_progress"
android:layout_alignParentStart="true"
android:layout_weight="1">
</android.support.v7.widget.Toolbar>
<ScrollView
android:id="#+id/scroll_container"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_above="#+id/linearLayout12"
android:layout_alignParentBottom="true"
android:layout_marginTop="?attr/actionBarSize"
android:layout_weight="0"
android:fillViewport="true">
<android.support.v7.widget.RecyclerView
android:id="#+id/message_table"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical">
</android.support.v7.widget.RecyclerView>
</ScrollView>
<LinearLayout
android:id="#+id/linearLayout12"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical"
android:layout_above="#+id/linearLayout8"
android:layout_alignParentLeft="true">
</LinearLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical"
android:id="#+id/linearLayout8"
android:layout_above="#+id/layout_inputfield"
android:layout_alignParentLeft="true">
</LinearLayout>
<LinearLayout
android:id="#+id/layout_inputfield"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical"
android:layout_alignParentBottom="true"
android:layout_alignParentLeft="true">
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="50dp"
android:orientation="horizontal">
<LinearLayout
android:id="#+id/linearLayout6"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_centerVertical="true"
android:gravity="center_vertical"
android:orientation="horizontal">
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="wrap_content">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal">
<ImageView
android:id="#+id/imageView19"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="0"
android:src="#drawable/test" />
<ImageView
android:id="#+id/imageView18"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_weight="1"
android:scaleType="fitXY"
android:src="#drawable/test2" />
<ImageView
android:id="#+id/imageView7"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="0"
android:src="#drawable/test3" />
</LinearLayout>
<EditText
android:id="#+id/edit_input"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_centerVertical="true"
android:layout_weight="1"
android:background="#android:color/transparent"
android:ems="10"
android:inputType="textMultiLine"
android:textColor="#android:color/black">
<requestFocus />
</EditText>
</RelativeLayout>
</LinearLayout>
</RelativeLayout>
</LinearLayout>
</RelativeLayout>
The problem is that the UI is cut when the keyboard is uploaded.
So I solved it with the [adjustpan] option.
This is the same result as I intended.
But I can't even see the "toolbar."
I always want to show "toolbar" at the top.
1
2
I'll attach the image to the current situation more easily.
If you need any information, please let me know.

Button not displaying in layout

This is my XML:
<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:id="#+id/main_layout"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical"
tools:context=".MainActivity">
<LinearLayout
android:id="#+id/logoLayout"
android:layout_width="150dp"
android:layout_height="40dp"
android:layout_marginLeft="120dp"
android:layout_marginTop="25dp"
android:orientation="vertical">
<ImageView
android:id="#+id/imageView3"
android:layout_width="match_parent"
android:layout_height="wrap_content"
app:srcCompat="#drawable/csr_logo2" />
</LinearLayout>
<LinearLayout
android:id="#+id/lineLayout"
android:layout_width="match_parent"
android:layout_height="2dp"
android:layout_below="#+id/logoLayout"
android:layout_marginBottom="15dp"
android:layout_marginTop="5dp"
android:orientation="vertical">
<ImageView
android:id="#+id/imageView4"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="#drawable/dotted_line"
app:srcCompat="#drawable/dotted_line" />
<ImageView
android:id="#+id/imageView5"
android:layout_width="match_parent"
android:layout_height="match_parent"
app:srcCompat="#drawable/normal_line" />
</LinearLayout>
<android.support.design.widget.TabLayout
android:id="#+id/tabLayout"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="#color/white"
android:minHeight="?attr/actionBarSize"
android:textColor="#color/black"
android:theme="#style/AppTheme"
app:tabMode="scrollable" />
<com.example.sparsh.newcsraudit.CustomViewPager
android:id="#+id/pager"
android:layout_width="match_parent"
android:layout_height="wrap_content">
</com.example.sparsh.newcsraudit.CustomViewPager>
<LinearLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:orientation="horizontal">
<Button
android:id="#+id/completeBtn"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentBottom="true"
android:text="Complete Audit" />
</LinearLayout>
</LinearLayout>
The 'Button' doesn't display in the layout.
My button needs to be displayed in every category of the layout.
Tried adding button to my activity that holds the categories, but it's not working.
Tried making adjustments, but didn't succeed.
Also, looked for similar questions online, but couldn't find the solution.
How do I make the button display in the layout.
Please help!
Try this change your root Layout to RelativeLayout and make your Button android:layout_alignParentBottom="true"
And make your
<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:id="#+id/main_layout"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical"
tools:context=".MainActivity">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical">
<LinearLayout
android:id="#+id/logoLayout"
android:layout_width="150dp"
android:layout_height="40dp"
android:layout_marginLeft="120dp"
android:layout_marginTop="25dp"
android:orientation="vertical">
<ImageView
android:id="#+id/imageView3"
android:layout_width="match_parent"
android:layout_height="wrap_content"
app:srcCompat="#drawable/kid_goku" />
</LinearLayout>
<LinearLayout
android:id="#+id/lineLayout"
android:layout_width="match_parent"
android:layout_height="2dp"
android:layout_below="#+id/logoLayout"
android:layout_marginBottom="15dp"
android:layout_marginTop="5dp"
android:orientation="vertical">
<ImageView
android:id="#+id/imageView4"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="#drawable/ic_message"
app:srcCompat="#drawable/ic_message" />
<ImageView
android:id="#+id/imageView5"
android:layout_width="match_parent"
android:layout_height="match_parent"
app:srcCompat="#drawable/kid_goku" />
</LinearLayout>
<android.support.design.widget.TabLayout
android:id="#+id/tabLayout"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="#color/white"
android:minHeight="?attr/actionBarSize"
android:textColor="#color/colorPrimary"
android:theme="#style/AppTheme"
app:tabMode="scrollable" />
<com.example.sparsh.newcsraudit.CustomViewPager
android:id="#+id/pager"
android:layout_width="match_parent"
android:layout_height="wrap_content">
</com.example.sparsh.newcsraudit.CustomViewPager>
</LinearLayout>
<Button
android:id="#+id/completeBtn"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentBottom="true"
android:text="Complete Audit" />
</RelativeLayout>

ScrollView is not working inside the FrameLayout

The Below is my code i am not able to scroll the layout looking weird when i put scrollview
<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="match_parent"
android:background="#0099cc"
tools:context="willapp.stpl.com.willapp.util.ActivityPrintView">
<ScrollView
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:fillViewport="true"
android:orientation="horizontal">
<!-- The primary full-screen view. This can be replaced with whatever view
is needed to present your content, e.g. VideoView, SurfaceView,
TextureView, etc. -->
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:id="#+id/rootLayout">
<LinearLayout
android:id="#+id/table1heading"
android:layout_width="match_parent"
android:layout_height="wrap_content"
>
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Select executer's relationship"
android:id="#+id/txtHeading"/>
</LinearLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal"
android:padding="5dp"
android:id="#+id/mainactivity_layoutName"
android:layout_below="#+id/table1heading"
android:layout_centerVertical="true" >
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:id="#+id/mainactivity_txtLabelName"
android:text="Full Name:"/>
<View
android:layout_width="0dp"
android:layout_height="0dp"
android:layout_weight="1">
</View>
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:id="#+id/mainactivity_txtValueName"
android:text="Sssdadaad"/>
</LinearLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal"
android:id="#+id/mainactivity_layoutLine1"
android:padding="5dp"
android:layout_below="#+id/mainactivity_layoutName"
android:layout_centerVertical="true" >
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:id="#+id/mainactivity_txtLabelLine1"
android:text="Address Line1:"/>
<View
android:layout_width="0dp"
android:layout_height="0dp"
android:layout_weight="1">
</View>
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:id="#+id/mainactivity_txtValueLine1"
android:text="Sssdadaad"/>
</LinearLayout>
</RelativeLayout>
</ScrollView>
</FrameLayout>
Inside ScrollView try to use LinearLayout instead of RelativeLayout.
Something like this:
<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="match_parent"
android:background="#0099cc"
tools:context="willapp.stpl.com.willapp.util.ActivityPrintView">
<ScrollView
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:fillViewport="true"
android:orientation="horizontal">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content">
// and here your main Relative layout
</LinearLayout>
</ScrollView>
</FrameLayout>

Remove Strange Space between RecyclerView Items

I am newbie to android development and learning it to my own. I have a very strange problem of having strange space that comes in between every item of my recycler view. I have the following:
My recycler view is vertical with grid view layout of 2 spans(columns). What I have been trying is:
Code for Layout
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginLeft="#dimen/size_five"
android:layout_marginRight="#dimen/size_five"
android:layout_marginTop="#dimen/size_fifteen"
android:background="#color/blackColor"
android:clickable="true"
android:focusable="true"
android:orientation="vertical">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="0dp"
android:layout_weight="50">
<ImageView
android:id="#+id/album_image"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:background="#color/blackColor"
/>
</LinearLayout>
<LinearLayout
android:id="#+id/lowerline"
android:layout_width="match_parent"
android:layout_height="0dp"
android:layout_weight="15"
android:background="#color/hotpinkColor"
android:orientation="horizontal">
<LinearLayout
android:layout_width="0dp"
android:layout_height="match_parent"
android:layout_weight="4"
android:orientation="horizontal">
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_marginLeft="#dimen/size_ten">
<TextView
android:id="#+id/album_title_text"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerVertical="true"
android:gravity="left"
android:text="Album Title"
android:textColor="#color/whiteColor"
android:textSize="#dimen/size_eight"
android:textStyle="bold"/>
</RelativeLayout>
</LinearLayout>
<LinearLayout
android:layout_width="0dp"
android:layout_height="match_parent"
android:layout_marginRight="#dimen/size_ten"
android:layout_weight="5"
android:orientation="horizontal">
<LinearLayout
android:layout_width="0dp"
android:layout_height="match_parent"
android:layout_weight="1">
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="match_parent">
<ImageView
android:id="#+id/downloader"
android:layout_width="#dimen/size_thirty_six"
android:layout_height="#dimen/size_thirty_six"
android:layout_centerInParent="true"
android:src="#drawable/donwloaderimager"/>
</RelativeLayout>
</LinearLayout>
<LinearLayout
android:layout_width="0dp"
android:layout_height="match_parent"
android:layout_weight="1">
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="match_parent">
<ImageView
android:id="#+id/setteraswall"
android:layout_width="#dimen/size_fourty"
android:layout_height="#dimen/size_fourty"
android:layout_centerInParent="true"
android:src="#drawable/setteras"/>
</RelativeLayout>
</LinearLayout>
</LinearLayout>
</LinearLayout>
</LinearLayout>
</LinearLayout>
Screen Shot
The Black space is showing the extra strange space that I want to remove.
Change:
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="0dp"
android:layout_weight="50">
<ImageView
android:id="#+id/album_image"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:background="#color/blackColor"
/>
</LinearLayout>
to
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="0dp"
android:layout_weight="50">
<ImageView
android:id="#+id/album_image"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:background="#color/blackColor"
/>
</LinearLayout>
That is change the height of the second parent linear layout to wrap_content

Android put Cardview top of parent Cardview in RelativeLayout

how can i put cardview on top of parent cardview in below screen shot?
when i put image to CardView that cause of broken my view
correct view must be:
My xml layout:
<?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"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="#drawable/content_background">
<android.support.design.widget.CoordinatorLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical">
<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.support.v7.widget.Toolbar
android:id="#+id/activity_main_toolbar"
android:layout_width="match_parent"
android:layout_height="65dp"
android:background="#color/colorPrimary"
android:titleTextColor="#ffffff">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="horizontal">
<com.joanzapata.iconify.widget.IconTextView
android:id="#+id/icon_signal_robot"
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:layout_marginRight="10dp"
android:clickable="true"
android:gravity="center|right"
android:shadowColor="#22000000"
android:shadowDx="3"
android:shadowDy="3"
android:shadowRadius="1"
android:text="{fa-android}"
android:textColor="#color/quote"
android:textSize="30sp"/>
<com.joanzapata.iconify.widget.IconTextView
android:id="#+id/icon_search_icon"
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:layout_marginRight="10dp"
android:clickable="true"
android:gravity="center|right"
android:shadowColor="#22000000"
android:shadowDx="3"
android:shadowDy="3"
android:shadowRadius="1"
android:text="{fa-search}"
android:textColor="#ffffff"
android:textSize="25sp"/>
<com.gigamole.library.ntb.NavigationTabBar
android:id="#+id/market_detail_navigation_tab_bar"
android:layout_width="90dp"
android:layout_height="30dp"
android:layout_gravity="center_vertical|left"
android:background="#drawable/bg_round_circle"
app:ntb_active_color="#4527A0"
app:ntb_animation_duration="150"
app:ntb_corners_radius="50dp"
app:ntb_inactive_color="#dddfec"
app:ntb_preview_colors="#array/red_wine"/>
<TextView
android:id="#+id/signal_application_detail_activity_title"
android:layout_width="0dp"
android:layout_height="match_parent"
android:layout_weight="1"
android:clickable="true"
android:gravity="center|right"
android:text="#string/app_name"
android:textColor="#ffffff"
android:textSize="19sp"/>
<ImageView
android:id="#+id/activity_main_hearing_status"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:layout_marginLeft="5dp"
android:layout_marginRight="10dp"
android:gravity="center|right"
android:src="#drawable/ic_antenna_white"/>
</LinearLayout>
</android.support.v7.widget.Toolbar>
</android.support.design.widget.AppBarLayout>
<LinearLayout
android:id="#+id/signal_loading_view"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_gravity="center"
android:background="#color/colorPrimary"
android:gravity="center"
android:orientation="vertical"
android:visibility="gone">
<TextView
android:id="#+id/loading_view_title"
android:layout_width="match_parent"
android:layout_height="50dp"
android:gravity="center"
android:text="#string/app_name"
android:textColor="#FFF"
android:textSize="35sp"
/>
<TextView
android:id="#+id/loading_view_description"
android:layout_width="match_parent"
android:layout_height="50dp"
android:gravity="center"
android:text="#string/app_description"
android:textColor="#FFF"
android:textSize="18dp"
/>
<com.zl.reik.dilatingdotsprogressbar.DilatingDotsProgressBar
android:id="#+id/dots_progressBar"
android:layout_width="match_parent"
android:layout_height="30dp"
android:color="#ffee00"
android:radius="4dp"
app:dd_animationDuration="300"
app:dd_horizontalSpacing="7dp"
app:dd_numDots="5"
app:dd_scaleMultiplier="1.5"
/>
</LinearLayout>
<RelativeLayout
android:id="#+id/frame"
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:layout_gravity="center_vertical"
android:background="#drawable/content_background">
<android.support.v7.widget.CardView
android:id="#+id/malam"
android:layout_width="match_parent"
android:layout_height="wrap_content">
<ImageView
android:id="#+id/imageView2"
android:layout_width="match_parent"
android:layout_height="230dp"
android:scaleType="centerCrop"
android:src="#drawable/background"/>
</android.support.v7.widget.CardView>
<LinearLayout
android:id="#+id/linearLayout3"
android:layout_width="match_parent"
android:layout_height="180dp"
android:layout_alignParentTop="true"
android:layout_centerHorizontal="true"
android:layout_centerVertical="true"
android:layout_marginLeft="30dp"
android:layout_marginRight="30dp"
android:layout_marginTop="120dp"
android:fitsSystemWindows="true"
android:orientation="vertical">
<android.support.v7.widget.CardView
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_alignParentLeft="true"
android:layout_alignParentStart="true"
android:layout_alignParentTop="true"
app:cardCornerRadius="0dp"
app:elevation="2dp">
</android.support.v7.widget.CardView>
</LinearLayout>
<ImageView
android:id="#+id/robot_dialog_icon"
android:layout_width="65dp"
android:layout_height="65dp"
android:layout_alignBottom="#+id/malam"
android:layout_centerHorizontal="true"
android:layout_marginBottom="75dp"
android:fitsSystemWindows="true"
android:src="#drawable/dialog_robot_dialog"
app:layout_collapseMode="parallax"/>
</RelativeLayout>
</LinearLayout>
</android.support.design.widget.CoordinatorLayout>
</FrameLayout>
Frame and coordinator layout work in the same way: The first View is the most background, the next View is located on the top of the previous.
So I think you should just change the order of your CardViews in xml.
You also could try to use android:elevation in order to achhive desirable result.
After some tries I have achived such result:
My xml is:
<?xml version="1.0" encoding="utf-8"?>
<android.support.design.widget.CoordinatorLayout
android:id="#+id/frame"
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:layout_gravity="center_vertical"
android:background="#color/colorAccent">
<android.support.v7.widget.CardView
android:id="#+id/malam"
android:layout_width="match_parent"
android:layout_height="wrap_content">
<ImageView
android:id="#+id/imageView2"
android:layout_width="match_parent"
android:layout_height="230dp"
android:scaleType="centerCrop"
android:background="#android:color/holo_blue_dark"/>
</android.support.v7.widget.CardView>
<android.support.v7.widget.CardView
android:id="#+id/white_card"
android:layout_width="match_parent"
android:layout_height="180dp"
android:layout_marginLeft="30dp"
android:layout_marginRight="30dp"
android:layout_marginTop="120dp"
android:layout_centerHorizontal="true"
android:layout_centerVertical="true"
android:layout_alignParentLeft="true"
android:layout_alignParentStart="true"
android:layout_alignParentTop="true"
app:cardCornerRadius="0dp"
app:elevation="10dp">
</android.support.v7.widget.CardView>
<android.support.v7.widget.CardView
android:layout_width="65dp"
android:layout_height="65dp"
android:translationY="32dp"
app:layout_anchor="#id/white_card"
app:layout_anchorGravity="center_horizontal"
android:layout_gravity="center_horizontal">
<ImageView
android:id="#+id/robot_dialog_icon"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="#color/colorPrimary"/>
</android.support.v7.widget.CardView>
</android.support.design.widget.CoordinatorLayout>
CardView has default cardElevation=4. Because of that all other Views coming inside the same parent layout of that carview will be below that cardview.
In your code, the cardview with id 'malam' will be above other views because of the default cardElevation. Try setting its cardElevation as 0dp to override that.
<android.support.v7.widget.CardView
android:id="#+id/malam"
android:layout_width="match_parent"
android:layout_height="wrap_content"
app:cardElevation="0dp">
UPDATE
Setting 0dp will remove the shadow of that cardview. If shadow is required, then either
Remove cardElevation property from CardView "malam" & set "android:elevation" to the views with id "linearLayout3" & "robot_dialog_icon" so that value is greater than 4dp. (Note : This works for lollipop & higher versions only)
OR
Wrap "linearLayout3" & "robot_dialog_icon" inside individual CardViews.
I don't Understand what you want but I am thinking you want below thing.
If you want this type of like Image
Then use this Code.
xml code :
<?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"
android:paddingBottom="#dimen/activity_vertical_margin"
android:paddingLeft="#dimen/activity_horizontal_margin"
android:paddingRight="#dimen/activity_horizontal_margin"
android:paddingTop="#dimen/activity_vertical_margin"
app:layout_behavior="#string/appbar_scrolling_view_behavior"
tools:context="com.example.softeng.aab.MainActivity"
tools:showIn="#layout/activity_main">
<android.support.design.widget.CoordinatorLayout
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:orientation="vertical"
android:layout_width="match_parent"
android:layout_height="match_parent">
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_margin="5dp">
<android.support.v7.widget.CardView
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:card_view="http://schemas.android.com/apk/res-auto"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:id="#+id/card_view"
card_view:cardCornerRadius="1dp"
android:foreground="?android:attr/selectableItemBackground"
android:layout_marginTop="5dp">
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_gravity="center"
>
<ProgressBar
android:id="#+id/progress"
android:visibility="visible"
style="?android:attr/progressBarStyleSmall"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerInParent="true"
/>
</RelativeLayout>
<LinearLayout
android:id="#+id/content_loading"
android:visibility="invisible"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:gravity="center_vertical"
android:padding="5dp"
android:orientation="vertical">
<TextView
android:id="#+id/text_description"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textSize="#dimen/abc_text_size_medium_material"
android:layout_marginBottom="5dp" />
<TextView
android:id="#+id/text_owner"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textSize="#dimen/abc_text_size_small_material"
android:layout_marginBottom="5dp" />
<TextView
android:id="#+id/text_networks"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textSize="#dimen/abc_text_size_small_material"
/>
<LinearLayout
android:orientation="vertical"
android:layout_width="match_parent"
android:layout_height="5dp" />
</LinearLayout>
</android.support.v7.widget.CardView>
</RelativeLayout>
<LinearLayout
android:orientation="horizontal"
android:layout_width="wrap_content"
android:layout_height="100dp"
app:layout_anchor="#id/card_view"
app:layout_anchorGravity="right|end|bottom"
android:layout_marginRight="#dimen/fab_margin">
</LinearLayout>
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_margin="5dp"
>
<ImageView
android:id="#+id/image_avatar"
android:layout_width="20dp"
android:layout_height="20dp"
android:src="#android:color/holo_red_dark"
android:layout_centerHorizontal="true" />
</RelativeLayout>
</android.support.design.widget.CoordinatorLayout>
</RelativeLayout>
UpDate :
I think you require this
code :
<?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"
android:paddingBottom="#dimen/activity_vertical_margin"
android:paddingLeft="#dimen/activity_horizontal_margin"
android:paddingRight="#dimen/activity_horizontal_margin"
android:paddingTop="#dimen/activity_vertical_margin"
app:layout_behavior="#string/appbar_scrolling_view_behavior"
tools:context="com.example.softeng.aab.MainActivity"
tools:showIn="#layout/activity_main">
<android.support.design.widget.CoordinatorLayout
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:orientation="vertical"
android:layout_width="match_parent"
android:layout_height="match_parent">
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_margin="5dp"
>
<android.support.v7.widget.CardView
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:card_view="http://schemas.android.com/apk/res-auto"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:id="#+id/card_view"
card_view:cardCornerRadius="1dp"
android:foreground="?android:attr/selectableItemBackground"
android:layout_marginTop="5dp">
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_gravity="center"
>
<ProgressBar
android:id="#+id/progress"
android:visibility="visible"
style="?android:attr/progressBarStyleSmall"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerInParent="true"
/>
</RelativeLayout>
<LinearLayout
android:id="#+id/content_loading"
android:visibility="invisible"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:gravity="center_vertical"
android:padding="5dp"
android:orientation="vertical">
<TextView
android:id="#+id/text_description"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textSize="#dimen/abc_text_size_medium_material"
android:layout_marginBottom="5dp" />
<TextView
android:id="#+id/text_owner"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textSize="#dimen/abc_text_size_small_material"
android:layout_marginBottom="5dp" />
<TextView
android:id="#+id/text_networks"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textSize="#dimen/abc_text_size_small_material"
/>
<LinearLayout
android:orientation="vertical"
android:layout_width="match_parent"
android:layout_height="5dp" />
</LinearLayout>
</android.support.v7.widget.CardView>
</RelativeLayout>
<LinearLayout
android:orientation="horizontal"
android:layout_width="wrap_content"
android:layout_height="100dp"
app:layout_anchor="#id/card_view"
app:layout_anchorGravity="right|end|bottom"
android:layout_marginRight="#dimen/fab_margin">
</LinearLayout>
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="100dp"
android:layout_margin="5dp"
>
<de.hdodenhof.circleimageview.CircleImageView
android:id="#+id/image_avatar"
android:layout_width="20dp"
android:layout_height="20dp"
android:src="#android:color/holo_red_dark"
android:layout_centerHorizontal="true" />
</RelativeLayout>
</android.support.design.widget.CoordinatorLayout>
</RelativeLayout>
To Change Image in Round Shape just Change ImageView to de.hdodenhof.circleimageview.CircleImageView it will solve your problem.
add below dependecies in build.gradle file to create Round image.
compile 'de.hdodenhof:circleimageview:2.0.0

Categories

Resources