我如何能实现像从谷歌播放一个可折叠的看法? [英] How can I implement a collapsible view like the one from Google Play?

查看:123
本文介绍了我如何能实现像从谷歌播放一个可折叠的看法?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想实现一个可折叠的视图,酷似从谷歌播放市场之一。它显示一个数从内容行,箭头,和攻丝的箭头揭示的全部内容。这是实现与ExpandableListView或有任何其他的解决办法?

I want to implement a collapsible view, exactly like the one from Google Play market. It displays a number of rows from the content, and an arrow, and tapping on the arrow reveals the whole content. Is this implemented with the ExpandableListView or is there any other solution?

附突出我所期待的屏幕截图。 谢谢你。

Screen shots attached with highlighting what I am looking for. Thanks.

推荐答案

还有一个更简单的方法:

There is a simpler way:

        final TextView descriptionText = (TextView) view.findViewById(R.id.detail_description_content);
        final TextView showAll = (TextView) view.findViewById(R.id.detail_read_all);
        showAll.setOnClickListener(new OnClickListener() {
            @Override
            public void onClick(View v) {
                showAll.setVisibility(View.INVISIBLE);

                descriptionText.setMaxLines(Integer.MAX_VALUE);
            }
        });

XML:

<?xml version="1.0" encoding="utf-8"?>
<ScrollView xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="match_parent"
    android:layout_height="match_parent">
    <LinearLayout
        android:id="@+id/detail_description_container"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:orientation="vertical"
        >

        <TextView
            android:id="@+id/detail_description_content"
            android:maxLines="5"
            android:layout_width="match_parent"
            android:layout_height="wrap_content"/>
        <TextView
            android:id="@+id/detail_read_all"
            android:clickable="true"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"/>
    </LinearLayout>
</ScrollView>

最重要的部分是maxlines的和滚动视图。这并没有给一个缓慢的动画(这将是一个出价更复杂),但瞬间开放的效果。

The important part is maxlines and scrollview. This doesn't give a slow animation (that would be a bid more complex) but an instant open effect.

这篇关于我如何能实现像从谷歌播放一个可折叠的看法?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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