暗影分离Android的片段之间 [英] Shadow Separator Between Android Fragments

查看:127
本文介绍了暗影分离Android的片段之间的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我也有类似的ICS的Gmail应用程序的平板电脑( ListFragment 在右边的左边和内容)的布局,我想知道我怎么能去构建布局使得在两个片段之间的阴影分离器(像在Gmail应用,下面示出)

I have a layout similar to the ICS Gmail app for tablets (ListFragment on the left and content on the right) and I was wondering how I could go about constructing the layouts such that there is a shadow separator between the two fragments (like in the Gmail app, shown below)

.

此外,由于这是适用于这个问题,我怎么能有在活动列表项的布局很好的三角/箭头标记?我认为要实现这一点,ListView控件本身必须位于上面的阴影图层,但我不知道如何创建。

Also, as this is applicable to this question, how can I have that nice triangle/arrow marker in the active list item's layout? I assume to implement this, the ListView itself must lie above the shadow "layer", but I have no idea how to create that.

推荐答案

只是为了让大家知道(因为似乎有一个缺乏信息在那里对这个话题),这是个人的背景选择XML内实现表行的观点。例如,这是主屏幕的布局,

Just to let everyone know (because there seems to be a lack of information out there on this topic), this is achieved within the background selector XML of the individual list rows' view. For example, this is the main screen's layout,

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

但魔术进来的 list_item_selector

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

通过定义这些为9补丁可绘这样,你可以有每个项目有助于它的影子在中间的线宽的价值,当它被激活,阴影的部分将用箭头取代。我希望这可以帮助别人,因为它肯定帮助我!

By defining these as 9-patch drawables like this, you can have each list item contribute it's width worth of shadow to that line in the middle, and when it is activated, that segment of shadow will be replaced by an arrow. I hope this helps someone, as it's sure helped me!

这篇关于暗影分离Android的片段之间的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆