View的大小?PopuupWindow应用

ihrthk Boss直聘 Android开发工程师  2013-01-28 04:44:36
popup_more_account.xml


<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="200.0dip"
android:layout_height="wrap_content"
android:background="@drawable/backgroundport"
android:orientation="vertical" >

<ListView
android:id="@+id/lv_popup_accounts"
android:layout_width="200.0dip"
android:layout_height="wrap_content"
android:cacheColorHint="#00000000"
android:listSelector="@drawable/list_selector" >
</ListView>

</LinearLayout>


item_account_list.xml

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:descendantFocusability="blocksDescendants"
android:padding="5dip" >

<TextView
android:id="@+id/txt_user_account"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="bottom"
android:singleLine="true"
android:text="20101681"
android:textColor="@color/black"
android:textSize="20.0dip" />

<ImageButton
android:id="@+id/txt_user_delete"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginLeft="60dip"
android:background="@drawable/btn_delete_user"
android:focusable="false"
android:textSize="15.0dip" />

</LinearLayout>




View moreAccountView = LayoutInflater.from(LoginActivity.this)
.inflate(R.layout.popup_more_account, null);

ListView lvAccounts = (ListView) moreAccountView
.findViewById(R.id.lv_popup_accounts);
ListViewAccountAdapter adapter = new ListViewAccountAdapter(
LoginActivity.this);
lvAccounts.setAdapter(adapter);

lvAccounts.measure(0, 0);
int height = lvAccounts.getMeasuredHeight();

PopupWindow mPopupWindow = new PopupWindow(moreAccountView,
edtAccount.getWidth(), height);
Drawable backgroup = LoginActivity.this.getResources()
.getDrawable(R.drawable.transparent);
mPopupWindow.setBackgroundDrawable(backgroup);

int pos[] = new int[2];
edtAccount.getLocationOnScreen(pos);

mPopupWindow.showAtLocation(edtAccount, Gravity.LEFT
| Gravity.TOP, pos[0], pos[1] + edtAccount.getHeight());

我想要的效果就是moreAccountView里多少内容,moreAccountView就有多高,请问怎么实现?

...全文
41 点赞 收藏 1
写回复
1 条回复
ihrthk 2013年01月29日
自顶一下,求解。
回复 点赞
发动态
发帖子
Android
创建于2009-10-09

4.6w+

社区成员

9.0w+

社区内容

移动平台 Android
社区公告
暂无公告