java - 使用 ListView 和 ScrollView 在 fragment 上放置阴影

标签 java android

我在使用 ListView 和 ScrollView 以及在 ListView 和 ScrollView 之间添加投影时遇到问题。

我制作了一个形状,它适用于 ListView 和相关布局,但不适用于 ScrollView。

我做了以下 - 仪表板列表

<?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>

带 ScrollView 的仪表板

<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>

查看

<?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>

编辑 - 附加屏幕截图

What I want - Got that working without ScrollView With ScrollView

谢谢大家 詹姆斯

最佳答案

似乎您缺少“带 ScrollView 的仪表板”上的填充

试试这个吧

<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>

关于java - 使用 ListView 和 ScrollView 在 fragment 上放置阴影,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/24736332/

相关文章:

java - 从 java 调用 shell 脚本挂起

java - 用于关闭 JDialog 的按钮

java - 用于多个标签的 JScrollPane

用于可重用代码的 Android StartActivityForResult - 还有其他方法吗? (关于推特)

android - 仅设置 webViewClient 就会导致在 webview 内打开链接

java - Ant 替换任务损坏 UTF-8 文件中的符号

java - 可滚动弧形轮 查看

java - DexArchiveMergerException 程序类型已存在 : a. a.a

android - 可以像 android 中的窗口一样使 View 不可触摸吗?

android - 视频流和安卓