如图片上的这种显示文本内容的控件用的是什么控件,如何实现的,求指导

解决方案 »

  1.   

    自己写个java类MyAffair继承自relativeLayout
    然后在构造方法里面inflate一个跟这个空间差不多的xml
    xml里面有很多textview,按照图片上的摆放。
    在MyAffair中设置一些方法,比如说setName setApartment setJob等等。
      

  2.   

    放内容的地方是重写的textview控件吗?我百度了一些没见过有这样的例子
      

  3.   

    不是重写textview,是添加一个xml
      

  4.   

    你先写个xml布局文件,最外层是relativelayout,里面放textview按照你这个图的位置摆放。然后在重写一个自己的view继承自RelativeLayout,并且在构造方法里面把写好的布局文件inflate进去。就可以了。
      

  5.   

    个人感觉应该是一个button,下面放个layout,平时layout不可见,visibility设为gone,点击button的时候,layout设置为可见,这样的效果应该和楼主说的差不多。
      

  6.   

    你先写个xml布局文件,最外层是relativelayout,里面放textview按照你这个图的位置摆放。然后在重写一个自己的view继承自RelativeLayout,并且在构造方法里面把写好的布局文件inflate进去。就可以了。谢谢,我试一下
      

  7.   

    上班儿没事儿,简单的给你写了个demo。具体的方法逻辑和命名你可以拿回去修改。
    下载地址 http://download.csdn.net/detail/wlcw16/5478995没有什么难的。就是自定义的widget。看看你应该就明白了。主要的控件类。图片请自行定义。package com.example.zdemo9;import android.animation.Animator.AnimatorListener;
    import android.animation.Animator;
    import android.animation.ObjectAnimator;
    import android.content.Context;
    import android.util.AttributeSet;
    import android.view.LayoutInflater;
    import android.view.View;
    import android.view.animation.Animation;
    import android.view.animation.Animation.AnimationListener;
    import android.widget.ImageView;
    import android.widget.RelativeLayout;public class MyAffair extends RelativeLayout {    private Context mContext;    private RelativeLayout titleRl;    private RelativeLayout infoRl;    private ImageView directionIv;    private View baseV;    private boolean isOpened = false;    private boolean animatorLock = false;    public MyAffair(Context context, AttributeSet attrs, int defStyle) {
            super(context, attrs, defStyle);
            mContext = context;
            init();
        }    public MyAffair(Context context, AttributeSet attrs) {
            this(context, attrs, 0);
        }    public MyAffair(Context context) {
            this(context, null);
        }    private void init() {
            baseV = LayoutInflater.from(mContext).inflate(R.layout.affair, this);
            titleRl = (RelativeLayout) baseV.findViewById(R.id.affair_title_rl);
            infoRl = (RelativeLayout) baseV.findViewById(R.id.affair_info_rl);
            directionIv = (ImageView) baseV.findViewById(R.id.affair_direction_iv);
            directionIv.setBackgroundResource(R.drawable.p7_2_001);
            titleRl.setOnClickListener(new OnClickListener() {            @Override
                public void onClick(View v) {
                    if (!animatorLock) {
                        getObjectAnimator().start();
                        if(isOpened){
                            directionIv.setBackgroundResource(R.drawable.p7_2_001);
                        }
                        else {
                            directionIv.setBackgroundResource(R.drawable.p7_1_008);
                        }
                    }
                }
            });
        }    private ObjectAnimator getObjectAnimator() {
            AnimatorListener changeStatusListener = new AnimatorListener() {
                
                @Override
                public void onAnimationStart(Animator animation) {
                    animatorLock = true;
                    if(!isOpened){
                        infoRl.setVisibility(View.VISIBLE);
                    }
                }
                
                @Override
                public void onAnimationRepeat(Animator animation) {
                }
                
                @Override
                public void onAnimationEnd(Animator animation) {
                    if(isOpened){
                        infoRl.setVisibility(View.GONE);
                    }
                    isOpened = !isOpened;
                    animatorLock = false;
                }
                
                @Override
                public void onAnimationCancel(Animator animation) {
                }
            };
            ObjectAnimator result = null;
            if(!isOpened){
                result = ObjectAnimator.ofFloat(infoRl, "scaleY", 0, 1f);
            }
            else {
                result = ObjectAnimator.ofFloat(infoRl, "scaleY", 1f, 0);
            }
            result.setDuration(1000);
            result.addListener(changeStatusListener);
            return result;
        }}mainactivity 因为没有一点逻辑,所以就不网上贴了。affair xml 注意,value中要有color
    <?xml version="1.0" encoding="utf-8"?>
    <RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content" >    <RelativeLayout
            android:id="@+id/affair_title_rl"
            android:layout_width="fill_parent"
            android:layout_height="wrap_content"
            android:background="@color/gray" >        <TextView
                android:id="@+id/textView1"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:layout_alignParentLeft="true"
                android:layout_centerVertical="true"
                android:text="事务查看" />        <ImageView
                android:id="@+id/affair_direction_iv"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:layout_alignParentRight="true"
                android:layout_centerVertical="true" />
        </RelativeLayout>    <RelativeLayout
            android:id="@+id/affair_info_rl"
            android:layout_width="fill_parent"
            android:layout_height="wrap_content"
            android:scaleY="0"
            android:visibility="gone"
            android:layout_alignParentLeft="true"
            android:layout_below="@+id/affair_title_rl" >        <TextView
                android:id="@+id/textView2"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:layout_alignParentLeft="true"
                android:layout_alignParentTop="true"
                android:text="TextView" />        <TextView
                android:id="@+id/textView3"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:layout_alignParentTop="true"
                android:layout_centerHorizontal="true"
                android:text="TextView" />        <TextView
                android:id="@+id/textView4"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:text="TextView" 
                android:layout_below="@+id/textView2" />        <TextView
                android:id="@+id/textView5"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:layout_alignLeft="@+id/textView3"
                android:layout_below="@+id/textView3"
                android:text="TextView" />        <TextView
                android:id="@+id/textView6"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:text="TextView"
                android:layout_below="@+id/textView4"  />        <TextView
                android:id="@+id/textView7"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:layout_alignBaseline="@+id/textView6"
                android:layout_alignBottom="@+id/textView6"
                android:layout_alignLeft="@+id/textView5"
                android:text="TextView" />    </RelativeLayout></RelativeLayout>
    main xml<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:paddingBottom="@dimen/activity_vertical_margin"
        android:paddingLeft="@dimen/activity_horizontal_margin"
        android:paddingRight="@dimen/activity_horizontal_margin"
        android:paddingTop="@dimen/activity_vertical_margin"
        tools:context=".MainActivity" >    <LinearLayout
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_alignParentLeft="true"
            android:layout_alignParentTop="true"
            android:orientation="vertical" >        <com.example.zdemo9.MyAffair
                android:layout_width="wrap_content"
                android:layout_height="wrap_content" >
            </com.example.zdemo9.MyAffair>        <com.example.zdemo9.MyAffair
                android:layout_width="wrap_content"
                android:layout_height="wrap_content" >
            </com.example.zdemo9.MyAffair>        <com.example.zdemo9.MyAffair
                android:layout_width="wrap_content"
                android:layout_height="wrap_content" >
            </com.example.zdemo9.MyAffair>    </LinearLayout></RelativeLayout>