Add button above RecyclerView - android

I'm trying to add Button above RecyclerView, but it doesn't work :
<RelativeLayout
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
xmlns:ads="http://schemas.android.com/apk/res-auto"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical"
android:background="#008080"
tools:context=".fragmentUsers">
<!-- TODO: Update blank fragment layout -->
<Button
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="Send us"
android:layout_above="#+id/rc"/>
<android.support.v7.widget.RecyclerView
android:id="#+id/rc"
android:numColumns="2"
android:scrollbars="vertical"
android:layout_marginTop="2dp"
android:layout_above="#+id/adView"
android:layout_width="match_parent"
android:layout_height="match_parent" />
<TextView
android:id="#+id/loadingtext"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textSize="14sp"
android:gravity="center"
android:layout_centerHorizontal="true"
android:layout_centerVertical="true"
android:text="txt"/>
</RelativeLayout>

Replace your code with below code, that will help you what you want
<RelativeLayout
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
xmlns:ads="http://schemas.android.com/apk/res-auto"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical"
android:background="#008080"
>
<!-- TODO: Update blank fragment layout -->
<Button
android:id="#+id/your_id"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="Send us"
/>
<android.support.v7.widget.RecyclerView
android:layout_below="#+id/your_id"
android:id="#+id/rc"
android:numColumns="2"
android:scrollbars="vertical"
android:layout_marginTop="2dp"
android:layout_width="match_parent"
android:layout_height="match_parent" />
<TextView
android:id="#+id/loadingtext"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textSize="14sp"
android:gravity="center"
android:layout_centerHorizontal="true"
android:layout_centerVertical="true"
android:text="txt"/>

Related

Unable to add views after RecyclerView in NestedScrollView

<android.support.v4.widget.NestedScrollView
android:layout_width="match_parent"
android:layout_height="match_parent"
app:layout_behavior="android.support.design.widget.AppBarLayout$ScrollingViewBehavior"
android:fillViewport="true">
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
tools:context=".fragments.HomeFragment"
android:layout_marginBottom="60dp">
<TextView
android:id="#+id/cat_list_title"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="Popular Categories"
android:gravity="center"
android:padding="10sp"
android:textSize="18sp"
android:fontFamily="#fonts/Montserrat-SemiBold.ttf"/>
<android.support.v7.widget.RecyclerView
android:layout_below="#id/cat_list_title"
android:id="#+id/list"
android:layout_width="match_parent"
android:layout_height="match_parent">
</android.support.v7.widget.RecyclerView>
<TextView
android:layout_below="#id/list"
android:id="#+id/stats_title"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="#string/stats"
android:textSize="18sp"
android:gravity="center"
android:textColor="#color/black"
android:padding="10sp"/>
</RelativeLayout>
</android.support.v4.widget.NestedScrollView>
How do I add the TextView after the RecyclerView in the NestedScrollView?
When I added it, it doesnt show up... However, the textView above the RecyclerView works and is visible
set android:nestedScrollingEnabled="false" in RecyclerView
replace
<android.support.v4.widget.NestedScrollView
android:layout_width="match_parent"
android:layout_height="match_parent"
app:layout_behavior="android.support.design.widget.AppBarLayout$ScrollingViewBehavior"
android:fillViewport="true">
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
tools:context=".fragments.HomeFragment"
android:layout_marginBottom="60dp">
<TextView
android:id="#+id/cat_list_title"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="Popular Categories"
android:gravity="center"
android:padding="10sp"
android:textSize="18sp"
android:fontFamily="#fonts/Montserrat-SemiBold.ttf"/>
<android.support.v7.widget.RecyclerView
android:layout_below="#id/cat_list_title"
android:id="#+id/list"
android:layout_width="match_parent"
android:nestedScrollingEnabled="false"
android:layout_height="wrap_content">
</android.support.v7.widget.RecyclerView>
<TextView
android:layout_below="#id/list"
android:id="#+id/stats_title"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="#string/stats"
android:textSize="18sp"
android:gravity="center"
android:textColor="#color/black"
android:padding="10sp"/>
</RelativeLayout>
Try this code.. and change your needs according.
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout android:layout_width="match_parent"
android:layout_height="match_parent"
xmlns:android="http://schemas.android.com/apk/res/android" >
<android.support.v4.widget.NestedScrollView android:layout_width="match_parent"
android:layout_height="match_parent"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
app:layout_behavior="android.support.design.widget.AppBarLayout$ScrollingViewBehavior"
android:fillViewport="true"
xmlns:android="http://schemas.android.com/apk/res/android">
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
tools:context=".fragments.HomeFragment"
android:layout_marginBottom="60dp">
<TextView
android:id="#+id/cat_list_title"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="Popular Categories"
android:gravity="center"
android:padding="10sp"
android:textSize="18sp"
android:fontFamily="#fonts/Montserrat-SemiBold.ttf"/>
<android.support.v7.widget.RecyclerView
android:layout_below="#id/cat_list_title"
android:id="#+id/list"
android:layout_width="match_parent"
android:layout_height="match_parent">
</android.support.v7.widget.RecyclerView>
<TextView
android:layout_below="#id/list"
android:id="#+id/stats_title"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="#string/stats"
android:textSize="18sp"
android:gravity="center"
android:textColor="#color/black"
android:padding="10sp"/>
</RelativeLayout>
</android.support.v4.widget.NestedScrollView>
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="bottom"
android:text="Hello World"
android:layout_centerHorizontal="true"
android:layout_alignParentBottom="true"
android:layout_marginBottom="40dp"
android:layout_marginRight="20dp"
/>
</RelativeLayout>

Scrollview contains viewpager and one linearlayout

I tried to make a scrollable view with one ViewPager which will take 90% of the screen and then some useful information about images inside the ViewPager.
However, when I add the ScrollView widget, all sizes and weight doesn't work even if I set android:fillViewport="true". Here's my layout.
<?xml version="1.0" encoding="utf-8"?>
<android.support.v4.widget.NestedScrollView
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="wrap_content"
android:fillViewport="true">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical"
android:weightSum="100"
android:scrollbars="vertical">
<android.support.v7.widget.Toolbar
android:id="#+id/toolbar"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="#android:color/background_light"
android:elevation="0dp"
android:minHeight="?attr/actionBarSize"
android:theme="?attr/actionBarTheme"
app:popupTheme="?android:attr/homeAsUpIndicator" />
<LinearLayout
android:layout_width="match_parent"
android:layout_height="0dip"
android:layout_weight="90"
android:orientation="vertical"
android:padding="50dip">
<android.support.v4.view.ViewPager
android:id="#+id/product_sheet_viewpager"
android:layout_width="match_parent"
android:layout_height="match_parent"/>
</LinearLayout>
<TextView
android:id="#+id/product_sheet_description"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:text="bbb"/>
<TextView
android:id="#+id/product_sheet_color"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:text="Color: Yellow" />
<TextView
android:id="#+id/product_sheet_reference"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:text="Ref: 2049/889/300" />
</LinearLayout>
</android.support.v4.widget.NestedScrollView>
Remove the android:fillViewport="true" and set the layout_height of your NestedScrollView to match_parent.
So here's the final layout should look like.
<?xml version="1.0" encoding="utf-8"?>
<android.support.v4.widget.NestedScrollView
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:fillViewport="true">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical"
android:scrollbars="vertical"
android:weightSum="100">
<android.support.v7.widget.Toolbar
android:id="#+id/toolbar"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="#android:color/background_light"
android:elevation="0dp"
android:minHeight="?attr/actionBarSize"
android:theme="?attr/actionBarTheme"
app:popupTheme="?android:attr/homeAsUpIndicator" />
<LinearLayout
android:layout_width="match_parent"
android:layout_height="0dip"
android:layout_weight="90"
android:orientation="vertical"
android:padding="50dip">
<android.support.v4.view.ViewPager
android:id="#+id/product_sheet_viewpager"
android:layout_width="match_parent"
android:layout_height="match_parent" />
</LinearLayout>
<TextView
android:id="#+id/product_sheet_description"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:text="bbb" />
<TextView
android:id="#+id/product_sheet_color"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:text="Color: Yellow" />
<TextView
android:id="#+id/product_sheet_reference"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:text="Ref: 2049/889/300" />
</LinearLayout>
</android.support.v4.widget.NestedScrollView>
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
>
<RelativeLayout
android:id="#+id/relativeLayout"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:paddingBottom="5dp"
android:paddingTop="5dp"
android:layout_above="#+id/relativeLayoutBottom"
>
<android.support.v4.view.ViewPager
android:id="#+id/viewPagerPlanDetailBroucher"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:columnWidth="250dp"
android:numColumns="auto_fit"
android:verticalSpacing="1dp"
android:horizontalSpacing="1dp"
android:layout_marginRight="50dp"
android:layout_marginLeft="50dp"
>
</android.support.v4.view.ViewPager>
</RelativeLayout>
<RelativeLayout
android:id="#+id/relativeLayoutBottom"
android:layout_alignParentBottom="true"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:paddingBottom="5dp"
android:paddingTop="5dp"
>
<TextView
android:id="#+id/product_sheet_description"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerHorizontal="true"
android:text="bbb"/>
<TextView
android:id="#+id/product_sheet_color"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerHorizontal="true"
android:layout_below="#+id/product_sheet_description"
android:text="Color: Yellow" />
<TextView
android:id="#+id/product_sheet_reference"
android:layout_below="#+id/product_sheet_color"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerHorizontal="true"
android:text="Ref: 2049/889/300" />
</RelativeLayout>
</RelativeLayout>

show textview on google map in android

I am trying to place a TextView on GoogleMap in my android application. Please see the following code that I wrote so far. When I run it the TextView does not appear on the GoogleMap.
<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"
app:layout_behavior="#string/appbar_scrolling_view_behavior"
tools:context=".activity.HomeActivity"
tools:showIn="#layout/app_bar_main">
<LinearLayout
android:id="#+id/validity"
android:layout_width="match_parent"
android:layout_height="50dp"
android:orientation="vertical"
android:layout_alignParentBottom="true">
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="You are not a paid user."/>
</LinearLayout>
<fragment
android:id="#+id/home_map"
android:name="com.google.android.gms.maps.SupportMapFragment"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_alignParentLeft="false"
android:layout_alignParentStart="true"
android:layout_alignParentTop="true"
android:layout_alignParentBottom="true" />
</RelativeLayout>
Please suggest me possible solution to solve this issue.
Use FrameLayout instead of Relative Layout like this. I have tested this and this is working
<?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"
app:layout_behavior="#string/appbar_scrolling_view_behavior">
<fragment
android:id="#+id/home_map"
android:name="com.google.android.gms.maps.SupportMapFragment"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_alignParentLeft="false"
android:layout_alignParentStart="true"
android:layout_alignParentTop="true"
android:layout_alignParentBottom="true" />
<LinearLayout
android:id="#+id/validity"
android:layout_width="match_parent"
android:layout_height="50dp"
android:orientation="vertical"
android:layout_gravity="bottom"
android:background="#android:color/white">
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="You are not a paid user."
/>
</LinearLayout>
</FrameLayout>
Use This code
<fragment
android:id="#+id/home_map"
android:name="com.google.android.gms.maps.SupportMapFragment"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_alignParentLeft="false"
android:layout_alignParentStart="true"
android:layout_alignParentTop="true"
android:layout_alignParentBottom="true" />
<LinearLayout
android:id="#+id/validity"
android:layout_width="match_parent"
android:layout_height="50dp"
android:orientation="vertical"
android:layout_alignParentBottom="true">
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="You are not a paid user."/>
</LinearLayout>
<?xml version="1.0" encoding="utf-8"?>
<android.support.design.widget.CoordinatorLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="#EEE">
<LinearLayout
android:orientation="vertical"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:id="#+id/linear"
android:layout_marginTop="10dp"
android:gravity="center">
<ScrollView
android:layout_width="match_parent"
android:layout_height="wrap_content">
<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:layout_marginLeft="40dp"
android:layout_marginRight="40dp"
android:background="#ffffff">
<Spinner
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:id="#+id/spinner"
android:fontFamily="#string/fontmedium"
android:textColor="#color/normalfont"
android:textSize="16sp"
android:layout_marginLeft="10dp"
android:layout_marginRight="10dp"
>
</Spinner>
</LinearLayout>
<EditText
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginLeft="40dp"
android:layout_marginRight="40dp"
android:background="#drawable/borderss"
android:layout_marginTop="20dp"
android:padding="15dp"
android:gravity="center"
android:id="#+id/res_acc"
android:textAlignment="center"
android:imeOptions="actionDone"
android:fontFamily="#string/fontmedium"
android:textColor="#color/normalfont"
android:textSize="16sp"
android:hint="Enter City name"
/>
<android.support.v7.widget.AppCompatButton
android:id="#+id/details"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textStyle="bold"
android:textColor="#ffffff"
android:layout_marginRight="16dp"
android:layout_marginLeft="15dp"
android:fontFamily="#string/fontmedium"
android:textSize="14sp"
android:padding="10dp"
android:text=" View Map "
android:background="#drawable/receiptt"
android:layout_gravity="center"
android:layout_marginTop="20dp" />
</LinearLayout>
</ScrollView>
<fragment xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:map="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:id="#+id/map"
android:name="com.google.android.gms.maps.SupportMapFragment"
android:layout_width="match_parent"
android:layout_height="match_parent"
tools:context="com.example.map_sample" />
</LinearLayout>
</android.support.design.widget.CoordinatorLayout>

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

VideoView in full screen in landscape mode

I've the following XML with various element and I would like to have the only VideoView element expanded in fullscreen (like YouTube) when the device is in landscape mode:
<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:background="#FFFFFF"
tools:context=".VideoMapPanel" >
<com.sothree.slidinguppanel.SlidingUpPanelLayout
xmlns:sothree="http://schemas.android.com/apk/res-auto"
android:id="#+id/sliding_layout"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:gravity="bottom"
sothree:panelHeight="68dp"
sothree:shadowHeight="4dp"
sothree:paralaxOffset="100dp"
sothree:dragView="#+id/dragView"
>
<!-- MAIN CONTENT -->
<FrameLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical">
<android.support.v7.widget.Toolbar
xmlns:sothree="http://schemas.android.com/apk/res-auto"
xmlns:android="http://schemas.android.com/apk/res/android"
android:id="#+id/main_toolbar"
android:layout_height="?attr/actionBarSize"
android:background="?attr/colorPrimary"
sothree:theme="#style/ActionBar"
android:layout_width="match_parent"/>
<TextView
android:id="#+id/main"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_marginTop="?attr/actionBarSize"
android:gravity="center"
android:text="Main Content"
android:clickable="true"
android:focusable="false"
android:focusableInTouchMode="true"
android:textSize="16sp" />
<fragment
android:id="#+id/map"
android:layout_width="match_parent"
android:layout_height="match_parent"
class="com.google.android.gms.maps.MapFragment" />
</FrameLayout>
<!-- SLIDING LAYOUT -->
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="#eeeeee"
android:orientation="vertical"
android:clickable="true"
android:focusable="false"
android:id="#+id/dragView">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="68dp"
android:id="#+id/main_title_bar"
android:orientation="horizontal">
<TextView
android:id="#+id/tvName"
android:layout_width="0dp"
android:layout_height="match_parent"
android:layout_weight="1"
android:textSize="20sp"
android:textColor="#android:color/white"
android:textStyle="bold"
android:background="#FF8800"
android:gravity="center_vertical"
android:paddingLeft="10dp"/>
<ProgressBar
android:id="#+id/progressBar"
style="?android:attr/progressBarStyleLarge"
android:layout_width="50dip"
android:layout_height="match_parent"
android:gravity="center_vertical"
android:background="#FF8800"
android:visibility="gone" >
</ProgressBar>
<ImageView
android:id="#+id/tvLogo"
android:layout_width="50dip"
android:background="#FF8800"
android:layout_height="match_parent"
android:paddingRight="10dp"
android:gravity="center_vertical" />
</LinearLayout>
<VideoView
android:id="#+id/liveView"
android:clickable="true"
android:paddingLeft="10dp"
android:paddingRight="10dp"
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:layout_gravity="center"/>
<ImageButton
android:id="#+id/videoPlayButton"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:background="#null"
android:layout_gravity="center"
android:layout_margin="10dp"
android:src="#drawable/videoplaybutton" >
</ImageButton>
<LinearLayout
android:id="#+id/menuLayout"
android:background="#FFFFFF"
android:layout_width="match_parent"
android:layout_height="68dp"
android:orientation="horizontal">
<ImageButton
android:id="#+id/fbLogo"
android:background="#FFFFFF"
android:layout_width="fill_parent"
android:layout_height="match_parent"
android:layout_weight="0.8"
android:src="#drawable/facebook_logo"
/>
<ImageButton
android:id="#+id/twitterLogo"
android:background="#FFFFFF"
android:layout_width="fill_parent"
android:layout_height="match_parent"
android:layout_weight="0.8"
android:src="#drawable/twitter_logo"
/>
<ImageButton
android:id="#+id/webLogo"
android:background="#FFFFFF"
android:layout_width="fill_parent"
android:layout_height="match_parent"
android:layout_weight="0.8"
android:src="#drawable/web_logo"/>
</LinearLayout>
<ScrollView
android:layout_width="fill_parent"
android:layout_height="wrap_content" >
<com.myapp.tv.ExpandableTextView
android:id="#+id/tvDescription"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textSize="14sp"
android:textColor="#android:color/black"
android:gravity="center_vertical"
android:paddingTop="10dp"
android:paddingLeft="10dp"
android:paddingRight="10dp"/>
</ScrollView>
</LinearLayout>
</com.sothree.slidinguppanel.SlidingUpPanelLayout>
</RelativeLayout>
Should I solve this programmatically ?
I would solve this by using another layout file.
I would start by taking a look at http://developer.android.com/training/basics/supporting-devices/screens.html#create-layouts
Currently I imagine the layout you posted is saved at res/layout/my_layout.xml
What you could do is make another file res/layout-land/my_layout.xml and instead of the same layout define the layout will display the VideoView element in fullscreen.
If you are using the other components be sure to include them in the layout or handle null views gracefully in the code. You can include them in the layout by having them in but setting the visibility to gone.

Categories

Resources