主要是实现文档点击箭头时的显现与隐藏及箭头的变换。
最终实现效果:
首先是写好页面。
XML代码:
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical"
android:background="@color/white" >
<RelativeLayout
android:layout_width="fill_parent"
android:layout_height="45dp"
android:background="#0075C2" >
<ImageView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:src="@drawable/back"
android:layout_marginLeft="6dp"
android:layout_centerVertical="true"
/>
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="新手指南"
android:layout_centerInParent="true"
android:textColor="@color/white"
android:textSize="19sp"
android:textStyle="bold"
/>
</RelativeLayout>
<ScrollView
android:layout_width="fill_parent"
android:layout_height="wrap_content">
<LinearLayout
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:orientation="vertical"
>
<TextView
android:id="@+id/textview1"
android:background="@color/white"
android:layout_width="fill_parent"
android:layout_height="55dp"
android:text="为什么要身份证?"
android:gravity="center_vertical"
android:textColor="@color/heise"
android:textSize="18sp"
android:drawableLeft="@drawable/qq"
android:drawableRight="@drawable/godown"
android:paddingLeft="12dp"
android:paddingRight="12dp"
android:drawablePadding="12dp"
/>
<View
android:layout_width="fill_parent"
android:layout_height="0.5dp"
android:background="@color/index_line"
/>
<LinearLayout
android:id="@+id/linearlayout1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:orientation="horizontal"
android:background="@color/yincang"
android:visibility="gone"
>
<ImageView
android:layout_width="18dp"
android:layout_height="18dp"
android:src="@drawable/da"
android:layout_marginLeft="24dp"
android:layout_marginTop="15dp"
/>
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="为了确保您的电子账户为本人开立、保障个人账务安全。注册手机用户成功之后,需要完成个人身份认证,待系统认证审核完成,方可解绑本人借记卡,完成开户流程。之后可以实现您的电子账户充值、提现,以及购买产品等。"
android:layout_marginLeft="12dp"
android:layout_marginRight="20dp"
android:layout_marginTop="15dp"
android:textSize="14sp"
android:textColor="@color/ziti"
/>
</LinearLayout>
<View
android:layout_width="fill_parent"
android:layout_height="0.5dp"
android:background="@color/index_line"
/>
<TextView
android:id="@+id/textview2"
android:background="@color/white"
android:layout_width="fill_parent"
android:layout_height="55dp"
android:text="为什么要绑定银行卡?"
android:gravity="center_vertical"
android:textColor="@color/heise"
android:textSize="18sp"
android:drawableLeft="@drawable/qq"
android:drawableRight="@drawable/godown"
android:paddingLeft="12dp"
android:paddingRight="12dp"
android:drawablePadding="12dp"
/>
<View
android:layout_width="fill_parent"
android:layout_height="0.5dp"
android:background="@color/index_line"
/>
<LinearLayout
android:id="@+id/linearlayout2"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:orientation="horizontal"
android:background="@color/yincang"
android:visibility="gone"
>
<ImageView
android:layout_width="18dp"
android:layout_height="18dp"
android:src="@drawable/da"
android:layout_marginLeft="24dp"
android:layout_marginTop="15dp"
/>
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="为了确保您电子账户内的资金安全,需要先将电子账户与本人持有的任意银行借记卡账户绑定,才能将电子账户内的资金转出;目前每个用户只能绑定一张本人借记卡且只能通过绑定的借记卡进行与电子账户资金的互转。"
android:layout_marginLeft="12dp"
android:layout_marginRight="20dp"
android:layout_marginTop="15dp"
android:textSize="14sp"
android:textColor="@color/ziti"
/>
</LinearLayout>
<View
android:layout_width="fill_parent"
android:layout_height="0.5dp"
android:background="@color/index_line"
/>
<TextView
android:id="@+id/textview3"
android:background="@color/white"
android:layout_width="fill_parent"
android:layout_height="55dp"
android:text="如何绑定银行卡?"
android:gravity="center_vertical"
android:textColor="@color/heise"
android:textSize="18sp"
android:drawableLeft="@drawable/qq"
android:drawableRight="@drawable/godown"
android:paddingLeft="12dp"
android:paddingRight="12dp"
android:drawablePadding="12dp"
/>
<View
android:layout_width="fill_parent"
android:layout_height="0.5dp"
android:background="@color/index_line"
/>
<LinearLayout
android:id="@+id/linearlayout3"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:orientation="horizontal"
android:background="@color/yincang"
android:visibility="gone"
>
<ImageView
android:layout_width="18dp"
android:layout_height="18dp"
android:src="@drawable/da"
android:layout_marginLeft="24dp"
android:layout_marginTop="15dp"
/>
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="在开户流程完成身份认证后,需要输入您本人的借记卡卡号,系统判断是否为您本人的账户,验证通过即绑定成功。绑定成功后您可通过绑定借记卡向电子账户充值、进行产品购买等。"
android:layout_marginLeft="12dp"
android:layout_marginRight="20dp"
android:layout_marginTop="15dp"
android:textSize="14sp"
android:textColor="@color/ziti"
/>
</LinearLayout>
<View
android:layout_width="fill_parent"
android:layout_height="0.5dp"
android:background="@color/index_line"
/>
<TextView
android:id="@+id/textview4"
android:background="@color/white"
android:layout_width="fill_parent"
android:layout_height="55dp"
android:text="如何变更绑定卡?"
android:gravity="center_vertical"
android:textColor="@color/heise"
android:textSize="18sp"
android:drawableLeft="@drawable/qq"
android:drawableRight="@drawable/godown"
android:paddingLeft="12dp"
android:paddingRight="12dp"
android:drawablePadding="12dp"
/>
<View
android:layout_width="fill_parent"
android:layout_height="0.5dp"
android:background="@color/index_line"
/>
<LinearLayout
android:id="@+id/linearlayout4"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:orientation="horizontal"
android:background="@color/yincang"
android:visibility="gone"
>
<ImageView
android:layout_width="18dp"
android:layout_height="18dp"
android:src="@drawable/da"
android:layout_marginLeft="24dp"
android:layout_marginTop="15dp"
/>
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="如果您想更换绑定卡,可登陆小鸥BANK在“我的账户-绑定卡变更”进行绑卡变更。"
android:layout_marginLeft="12dp"
android:layout_marginRight="20dp"
android:layout_marginTop="15dp"
android:textSize="14sp"
android:textColor="@color/ziti"
/>
</LinearLayout>
<View
android:layout_width="fill_parent"
android:layout_height="0.5dp"
android:background="@color/index_line"
/>
</LinearLayout>
</ScrollView>
</LinearLayout>
PS:
1.滑动事件用ScrollView;
2.隐藏文件设置:android:visibility="gone"
然后在java中写点击事件。
先定义再初始化。
初始化语句:textview1 = (TextView)findViewById(R.id.textview1);
linearlayout1 =(LinearLayout)findViewById(R.id.linearlayout1);
判断点击事件与图片变化方法:(两种方法)
第一种:
textview1.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View arg0) {
if(i==false)
{
linearlayout1.setVisibility(View.VISIBLE);
textview1.setCompoundDrawablesWithIntrinsicBounds(getResources().getDrawable(R.drawable.qq), null, getResources().getDrawable(R.drawable.goon), null);
i=true;
}else
{
linearlayout1.setVisibility(View.GONE);
textview1.setCompoundDrawablesWithIntrinsicBounds(getResources().getDrawable(R.drawable.qq), null, getResources().getDrawable(R.drawable.godown), null);
i=false;
}
}
});
第二种:
textview2.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View arg0) {
if(linearlayout2.getVisibility()==View.GONE)
{
linearlayout2.setVisibility(View.VISIBLE);
textview2.setCompoundDrawablesWithIntrinsicBounds(getResources().getDrawable(R.drawable.qq), null, getResources().getDrawable(R.drawable.goon), null);
}else
{
linearlayout2.setVisibility(View.GONE);
textview2.setCompoundDrawablesWithIntrinsicBounds(getResources().getDrawable(R.drawable.qq), null, getResources().getDrawable(R.drawable.godown), null);
}
}
});
Java代码:
import android.app.Activity;
import android.os.Bundle;
import android.view.View;
import android.widget.LinearLayout;
import android.widget.TextView;
public class XinShouZhiNanActivity extends Activity {
private TextView textview1;
private TextView textview2;
private TextView textview3;
private TextView textview4;
private LinearLayout linearlayout1;
private LinearLayout linearlayout2;
private LinearLayout linearlayout3;
private LinearLayout linearlayout4;
private boolean i=false;
@Override
protected void onCreate(Bundle savedInstanceState) {
// TODO Auto-generated method stub
super.onCreate(savedInstanceState);
setContentView(R.layout.xinshouzhinan);
//初始化
textview1 = (TextView)findViewById(R.id.textview1);
textview2 = (TextView)findViewById(R.id.textview2);
textview3 = (TextView)findViewById(R.id.textview3);
textview4 = (TextView)findViewById(R.id.textview4);
linearlayout1 =(LinearLayout)findViewById(R.id.linearlayout1);
linearlayout2 =(LinearLayout)findViewById(R.id.linearlayout2);
linearlayout3 =(LinearLayout)findViewById(R.id.linearlayout3);
linearlayout4 =(LinearLayout)findViewById(R.id.linearlayout4);
textview1.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View arg0) {
if(i==false)
{
linearlayout1.setVisibility(View.VISIBLE);
textview1.setCompoundDrawablesWithIntrinsicBounds(getResources().getDrawable(R.drawable.qq), null, getResources().getDrawable(R.drawable.goon), null);
i=true;
}else
{
linearlayout1.setVisibility(View.GONE);
textview1.setCompoundDrawablesWithIntrinsicBounds(getResources().getDrawable(R.drawable.qq), null, getResources().getDrawable(R.drawable.godown), null);
i=false;
}
}
});
textview2.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View arg0) {
if(linearlayout2.getVisibility()==View.GONE)
{
linearlayout2.setVisibility(View.VISIBLE);
textview2.setCompoundDrawablesWithIntrinsicBounds(getResources().getDrawable(R.drawable.qq), null, getResources().getDrawable(R.drawable.goon), null);
}else
{
linearlayout2.setVisibility(View.GONE);
textview2.setCompoundDrawablesWithIntrinsicBounds(getResources().getDrawable(R.drawable.qq), null, getResources().getDrawable(R.drawable.godown), null);
}
}
});
textview3.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View arg0) {
if(linearlayout3.getVisibility()==View.GONE)
{
linearlayout3.setVisibility(View.VISIBLE);
textview3.setCompoundDrawablesWithIntrinsicBounds(getResources().getDrawable(R.drawable.qq), null, getResources().getDrawable(R.drawable.goon), null);
}else
{
linearlayout3.setVisibility(View.GONE);
textview3.setCompoundDrawablesWithIntrinsicBounds(getResources().getDrawable(R.drawable.qq), null, getResources().getDrawable(R.drawable.godown), null);
}
}
});
textview4.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View arg0) {
if(linearlayout4.getVisibility()==View.GONE)
{
linearlayout4.setVisibility(View.VISIBLE);
textview4.setCompoundDrawablesWithIntrinsicBounds(getResources().getDrawable(R.drawable.qq), null, getResources().getDrawable(R.drawable.goon), null);
}else
{
linearlayout4.setVisibility(View.GONE);
textview4.setCompoundDrawablesWithIntrinsicBounds(getResources().getDrawable(R.drawable.qq), null, getResources().getDrawable(R.drawable.godown), null);
}
}
});
}
}