showtext = showlist.getText().toString().trim();
if (showtext.equals("显示列表")) {
//设置包裹lv的linearlayout为VISIBLE
ll_lv.setVisibility(View.VISIBLE);
//endheight是2/3的屏幕高度
int endheight = mHeight * 2 / 3;
//设置top为2/3的屏幕高度的位置
ll_lv.setTop(endheight);
int top = lv.getTop();
int buttom = lv.getBottom();
//改变textview文字
showlist.setText("隐藏列表");
} else {
//设置包裹lv的linearlayout为GONE
ll_lv.setVisibility(View.GONE);
//设置top为屏幕高度的位置
ll_lv.setTop(mHeight);
showlist.setText("显示列表");
}
布局文件:
<?xml version="1.0" encoding="utf-8"?>
android:id="@+id/rl"
android:layout_width="match_parent"
android:layout_height="match_parent">
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical">
<!--
<!--android:id="@+id/title"-->
<!--android:background="@color/blue"-->
<!--android:layout_width="match_parent"-->
<!--android:layout_height="wrap_content"-->
<!--android:text=""-->
<!--android:gravity="center"-->
<!--android:textSize="@dimen/font_32"-->
<!--android:padding="15dp"/>-->
android:layout_width="match_parent"
android:layout_height="0dp"
android:layout_weight="1">
<com.amap.api.maps2d.MapView
android:id="@+id/map"
android:layout_width="match_parent"
android:layout_height="match_parent"/>
<LinearLayout
android:id="@+id/ll_lv"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="bottom|right"
android:background="#fff"
android:orientation="vertical"
android:padding="5dp">
android:id="@+id/tv_tuch"
android:layout_width="match_parent"
android:background="@color/black"
android:layout_height="wrap_content"/>
android:id="@+id/lv"
android:layout_width="match_parent"
android:layout_height="0dp"
android:layout_weight="1">
</FrameLayout>
<LinearLayout
android:id="@+id/ll_show"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical">
<View
android:id="@+id/view"
android:layout_width="match_parent"
android:layout_height="0.5dp"
android:background="#d0d0d0"/>
<TextView
android:id="@+id/showlist"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:gravity="center"
android:padding="15dp"
android:text="显示列表"/>
</LinearLayout>
想要实现效果:
点击隐藏列表 列表隐藏 点击显示列表 列表显示出来;
但是现在是 用VISIBLE,gone的话listview就全部显示出来了,不用gone的话一开始列表就显示出来了 不符合我们业务需求
求大神指点一二。