Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/visual-studio-code/3.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Android片段之间的阴影分隔符_Android_Android Layout_Android Fragments_Android Listfragment - Fatal编程技术网

Android片段之间的阴影分隔符

Android片段之间的阴影分隔符,android,android-layout,android-fragments,android-listfragment,Android,Android Layout,Android Fragments,Android Listfragment,我有一个类似ICS Gmail平板电脑应用程序的布局(ListFragment在左边,内容在右边),我想知道如何构建布局,使两个片段之间有一个阴影分隔符(如Gmail应用程序,如下所示) 此外,由于这适用于此问题,如何在活动列表项的布局中使用漂亮的三角形/箭头标记?我假设要实现这一点,ListView本身必须位于阴影“层”之上,但我不知道如何创建它。为了让每个人都知道(因为似乎缺少关于此主题的信息),这是在单个列表行视图的背景选择器XML中实现的。例如,这是主屏幕的布局 <Relativ

我有一个类似ICS Gmail平板电脑应用程序的布局(
ListFragment
在左边,内容在右边),我想知道如何构建布局,使两个片段之间有一个阴影分隔符(如Gmail应用程序,如下所示)

此外,由于这适用于此问题,如何在活动列表项的布局中使用漂亮的三角形/箭头标记?我假设要实现这一点,ListView本身必须位于阴影“层”之上,但我不知道如何创建它。

为了让每个人都知道(因为似乎缺少关于此主题的信息),这是在单个列表行视图的背景选择器XML中实现的。例如,这是主屏幕的布局

<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:id="@+id/list_row"
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    android:orientation="vertical"
    android:background="@drawable/list_item_selector">

    ...<!-- Rest of layout goes here -->

</RelativeLayout>

通过将这些定义为像这样的9个补丁,你可以让每个列表项贡献它的宽度值到中间的那一行,当它被激活时,阴影段将被一个箭头所代替。我希望这能帮助别人,因为它确实帮助了我

我想做和你想做的一样的事情;创建一个片段比另一个片段“更近”的效果

Roboguy的答案处理如何在列表项上有白色箭头“选择器”;我将尝试更具体地描述阴影。 另一个使用背景选择器的好例子可以在Google IO 2011应用程序的源代码中看到。获得源代码后,请查看fragment_dashboard.xml图标选择器

阴影分隔符是一个渐变,应用于视图的左侧。分为两部分

首先,“影子”本身:

res/shadow_left.xml


然后,要将其实际应用于布局,请执行以下操作:

布局/我的下一层


据我所知,这必须通过相对布局来完成。如果使用的是线性布局,则可以将整个线性布局包裹在相对布局内,然后使用渐变添加


请注意,如果执行此操作,渐变必须位于
下方;否则,渐变将在线性布局下绘制,因此您将看不到它。

这将是一个注释,因为它非常模糊。我记不清了,但三角形与“单一项目选择”有关,您可以将可绘图项应用于列表中选定的项目。所以,当列表中的一个项目被选中时,这个三角形实际上是一些.png。阴影也应该是一个“布局分隔符”,另一个.png应用于同一布局中的视图之间。例如,当列表只有三个项目时?如何将阴影应用到所有这些内容上?您在布局中使用fragment_shadow_left,但创建shadow_left资源。
<selector xmlns:android="http://schemas.android.com/apk/res/android">
    <item android:state_pressed="true" android:drawable="@drawable/list_pressed" />
    <item android:state_activated="true" android:drawable="@drawable/list_arrow_activated"  />
    <item android:drawable="@drawable/list_default" />
</selector>
<?xml version="1.0" encoding="utf-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android">
<gradient
    android:angle="0"
    android:startColor="#55000000" 
    android:endColor="#00000000"
    />
</shape>
<?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" >
<View
    android:layout_width="20dp"
    android:layout_height="fill_parent"
    android:background="@drawable/fragment_shadow_left" />
<ImageView
    android:id="@+id/imageview"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:layout_centerInParent="true" />
</RelativeLayout>