I'm having an issue with a ListView and a ScrollView and adding a drop shadow between the listview and the ScrollView.
I had made a shape, which works great with a ListView and a relative layout, but does not work with the ScrollView.
I have done the following - Dashboard List
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="vertical"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:paddingLeft="8dp"
android:paddingRight="8dp">
<ListView
android:id="#id/android:list"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_weight="1"
android:choiceMode = "singleChoice"
android:listSelector="#31ABD4"
android:drawSelectorOnTop="false"/>
<TextView android:id="#id/android:empty"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:text="No data"/>
</RelativeLayout>
Dashboard with scroll view
<ScrollView xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="fill_parent"
android:layout_height="fill_parent" >
<RelativeLayout
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:background="#color/white" >
<View
android:layout_width="10dp"
android:layout_height="fill_parent"
android:background="#drawable/shadow_left" />
</RelativeLayout>
</ScrollView>
View
<?xml version ="1.0" encoding="utf-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android">
<gradient
android:angle="180"
android:width="10dp"
android:centerX="0.1"
android:gravity="right"
android:startColor="#00000000"
android:endColor="#55000000"
android:type = "linear"
/>
</shape>
Edit - Attached Screenshots
Thank you all,
James
seems that you are missing the paddings on "Dashboard with scroll view"
try this instead
<ScrollView xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:paddingLeft="8dp"
android:paddingRight="8dp" >
<RelativeLayout
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:background="#color/white" >
<View
android:layout_width="10dp"
android:layout_height="fill_parent"
android:background="#drawable/shadow_left" />
</RelativeLayout>
</ScrollView>
Related
I am new to android programming and I am trying to scroll my recycler view over image
<?xml version="1.0" encoding="utf-8"?>
<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:id="#+id/rootRL"
android:orientation="vertical"
android:layout_width="fill_parent"
android:layout_height="160dp"
android:background="#drawable/mydrawable">
<android.support.v7.widget.RecyclerView
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_marginTop="160dp"
android:id="#+id/rv"/>
</FrameLayout>
When I scroll ,the recycler view scrolls under the image not over it.How can i achieve this effect ?
Try this:-
Using FrameLayout by setting backgroundImage:
<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:id="#+id/rootRL"
android:layout_width="match_parent"
android:layout_height="160dp"
android:layout_marginTop="160dp"
android:background="#drawable/tips"
android:orientation="vertical">
<android.support.v7.widget.RecyclerView
android:id="#+id/recycler_view"
android:layout_width="match_parent"
android:layout_height="match_parent" />
</FrameLayout>
Using LinearLayout by setting backgroundImage:
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:id="#+id/rootRL"
android:layout_width="match_parent"
android:layout_height="160dp"
android:layout_marginTop="160dp"
android:background="#drawable/tips"
android:orientation="vertical">
<android.support.v7.widget.RecyclerView
android:id="#+id/recycler_view"
android:layout_width="match_parent"
android:layout_height="match_parent" />
</LinearLayout>
Using RelativeLayout by setting backgroundImage:
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:id="#+id/rootRL"
android:layout_width="match_parent"
android:layout_height="160dp"
android:layout_marginTop="160dp"
android:background="#drawable/tips">
<android.support.v7.widget.RecyclerView
android:id="#+id/recycler_view"
android:layout_width="match_parent"
android:layout_height="match_parent" />
</RelativeLayout>
Using RelativeLayout with ImageView:
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:id="#+id/rootRL"
android:layout_width="match_parent"
android:layout_height="160dp"
android:layout_marginTop="160dp">
<ImageView
android:layout_width="match_parent"
android:layout_height="match_parent"
android:src="#drawable/tips" />
<android.support.v7.widget.RecyclerView
android:id="#+id/recycler_view"
android:layout_width="match_parent"
android:layout_height="match_parent" />
</RelativeLayout>
I am working on a app where the user actions add LinearLayout's to the pre-existing LinearLayout #+id/linLayout. Sometimes these additional layouts will go off the bottom of the screen so I have put the main LinearLayout within a ScrollView. When my app starts to go off the bottom of the screen it is able to scroll a little bit but not far enough to see everything. At a certain point it is not possible to continue because a Button is off screen and cannot be pressed. Can anybody tell me what I'm doing wrong?
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_marginStart="#dimen/activity_horizontal_margin"
app:layout_behavior="#string/appbar_scrolling_view_behavior"
tools:showIn="#layout/activity_main"
tools:context=".MainActivity">
<LinearLayout 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:orientation="vertical" >
<Button android:id="#+id/bGenerateExample"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="#string/generate_example" />
<ScrollView
xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="wrap_content">
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:id="#+id/linLayout"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:orientation="vertical" >
</LinearLayout>
</ScrollView>
</LinearLayout>
</RelativeLayout>
What about using weight_Sum?
<LinearLayout 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:orientation="vertical"
android_weight_sum=5 >
<Button android:id="#+id/bGenerateExample"
android:layout_width="match_parent"
android:layout_height="0dp"
android:layout_weight="1"
android:text="#string/generate_example" />
<ScrollView
xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="0dp"
android:layout_weight="4">
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:id="#+id/linLayout"
android:layout_width="match_parent"
android:layout_height="marth_parent"
android:orientation="vertical" >
</LinearLayout>
</ScrollView>
</LinearLayout>
now button covers %20 percent of screen and scrollView covers %80.You can change it easily with changing layout_weight values of scrollView, Button.
I'm learning Android Material from Slidenerd's video on Youtube. I got a problem when learn to make Recycler View on Drawer. But the position of Recycler View can't bottom of Image View. I want to throw that after the ImageView like another Material Design app. Let see the screenshot.
This is my code:
fragment_navigation_drawer.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="match_parent"
android:background="#EEE"
tools:context="com.balinez.wdharmana.doahindu.NavigationDrawerFragment">
<LinearLayout
android:id="#+id/containerDrawerImage"
android:background="#F88C00"
android:layout_width="match_parent"
android:layout_height="wrap_content">
<!-- TODO: Update blank fragment layout -->
<ImageView
android:layout_width="280dp"
android:layout_height="140dp"
android:layout_marginBottom="18dp"
android:src="#drawable/bg_galungan"
/>
</LinearLayout>
<android.support.v7.widget.RecyclerView
android:id="#+id/drawer_list"
android:layout_width="match_parent"
android:layout_height="wrap_content">
</android.support.v7.widget.RecyclerView>
</FrameLayout>
custom_row.xml
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="horizontal"
android:layout_width="match_parent"
android:layout_height="match_parent">
<ImageView
android:padding="8dp"
android:id="#+id/listIcon"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:src="#drawable/ic_bookmark1"
android:layout_gravity="center_vertical"
/>
<TextView
android:id="#+id/listText"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Doa Sehari-hari"
android:layout_gravity="center_vertical"
/>
</LinearLayout>
Activity_main.xml
<android.support.v4.widget.DrawerLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:id="#+id/drawer_layout"
android:layout_width="match_parent"
android:layout_height="match_parent">
<RelativeLayout
android:fitsSystemWindows="true"
android:layout_width="match_parent"
android:layout_height="match_parent"
tools:context=".MainActivity" >
<include android:id="#+id/app_bar"
layout="#layout/app_bar" style="#style/AppTheme.Base" />
<TextView
android:layout_below="#+id/app_bar"
android:text="#string/hello_world" android:layout_width="wrap_content"
android:layout_height="wrap_content" />
</RelativeLayout>
<fragment
android:layout_width="#dimen/nav_drawer_width"
android:layout_height="match_parent"
android:layout_gravity="start"
android:id="#+id/fragment_navigation_drawer"
app:layout="#layout/fragment_navigation_drawer"
android:name="com.balinez.wdharmana.doahindu.NavigationDrawerFragment"
tools:layout="#layout/fragment_navigation_drawer" />
</android.support.v4.widget.DrawerLayout>
Let's share if you also has same problem. Thanks for advance !
If it really not necessary to user FrameLayout as your parent, you can use RelativeLayout like I used.
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="#EEE"
tools:context="com.balinez.wdharmana.doahindu.NavigationDrawerFragment">
<LinearLayout
android:id="#+id/containerDrawerImage"
android:background="#F88C00"
android:layout_width="match_parent"
android:layout_height="wrap_content"
>
<!-- TODO: Update blank fragment layout -->
<ImageView
android:layout_width="280dp"
android:layout_height="140dp"
android:layout_marginBottom="18dp"
android:src="#drawable/beach"
/>
</LinearLayout>
<android.support.v7.widget.RecyclerView
android:id="#+id/drawer_list"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_below="#+id/containerDrawerImage"
>
</android.support.v7.widget.RecyclerView>
</RelativeLayout>
My listview is transparent. I changed it. But still it has a slight transparency. How to disable it as the text aren't viisble.
<?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"
android:background="#drawable/sportsbg">
<ListView
android:id="#+id/list"
android:layout_width="fill_parent"
android:layout_height="310dp"
android:layout_alignParentBottom="true"
android:background="#FFffffff"
android:divider="#color/lists_divider"
android:dividerHeight="1dp"
android:paddingLeft="10dp"
android:paddingRight="10dp"
android:paddingTop="0dp" />
</RelativeLayout>
You can set the background of your listview to
android:background="#FFFFFF"
where as
android:background="#FFffffff"
specifies a alpha.
I am trying to create an app in which i want to set the Frangmenttabhost Tabs in the middle of the screen.
I have so far made it on the bottom but cant move to the middle.
Would be appreciating a help.
Here is my code
<?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="match_parent"
android:orientation="vertical" >
<FrameLayout
android:id="#+id/realtabcontent"
android:layout_width="match_parent"
android:layout_height="0dip"
android:layout_weight="1" />
<android.support.v4.app.FragmentTabHost
android:id="#android:id/tabhost"
android:layout_width="match_parent"
android:layout_height="wrap_content" >
<FrameLayout
android:id="#android:id/tabcontent"
android:layout_width="0dp"
android:layout_height="0dp"
android:layout_weight="0" />
</android.support.v4.app.FragmentTabHost>