我有一个弹出窗口,并且添加了滚动视图作为其父布局。但它不起作用。如果我将滚动视图更改为差异布局,它的工作原理.. 基本上我有多个布局(相对和线性的混合),我希望它可以滚动。我已经删除了复杂的树结构布局,所以让代码看起来很简单..
<ScrollView xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:id="@+id/ScrollView1"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:fillViewport="true" >
<LinearLayout
android:id="@+id/LinearLayout2"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="@drawable/chatheadpop"
android:orientation="vertical" >
<TableRow
android:id="@+id/headerRow"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:padding="10dp" >
<ImageView
android:id="@+id/profilePic"
android:layout_width="0dp"
android:layout_height="110dp"
android:layout_marginRight="10dp"
android:layout_weight="0.40"
android:background="#ccc" />
<RelativeLayout
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="0.60" >
<TextView
android:id="@+id/phoneIcon"
android:layout_width="30dp"
android:layout_height="wrap_content"
android:layout_marginBottom="10dp"
android:textSize="18sp"
android:color="#ccc" />
<TextView
android:id="@+id/phoneField"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignBaseline="@+id/phoneIcon"
android:layout_toRightOf="@+id/phoneIcon"
android:maxLines="1"
android:singleLine="true"
android:textSize="18sp"
android:color="#aaa" />
<TextView
android:id="@+id/nameIcon"
android:layout_width="30dp"
android:layout_height="wrap_content"
android:layout_below="@+id/phoneIcon"
android:layout_marginBottom="10dp"
android:textSize="18sp"
android:color="#ccc" />
<TextView
android:id="@+id/nameField"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignBaseline="@+id/nameIcon"
android:layout_toRightOf="@+id/nameIcon"
android:maxLines="1"
android:singleLine="true"
android:textSize="18sp"
android:color="#aaa" />
<TextView
android:id="@+id/locationIcon"
android:layout_width="30dp"
android:layout_height="wrap_content"
android:layout_below="@+id/nameIcon"
android:layout_marginBottom="10dp"
android:textSize="18sp"
android:visibility="invisible"
android:color="#ccc" />
<TextView
android:id="@+id/locationField"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignBaseline="@+id/locationIcon"
android:layout_toRightOf="@+id/locationIcon"
android:maxLines="1"
android:singleLine="true"
android:textSize="16sp"
android:visibility="invisible"
android:color="#aaa" />
<TextView
android:id="@+id/jobIcon"
android:layout_width="30dp"
android:layout_height="wrap_content"
android:layout_below="@+id/locationIcon"
android:layout_marginBottom="10dp"
android:textSize="18sp"
android:visibility="invisible"
android:color="#ccc" />
<TextView
android:id="@+id/jobField"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignBaseline="@+id/jobIcon"
android:layout_toRightOf="@+id/jobIcon"
android:maxLines="1"
android:singleLine="true"
android:textSize="16sp"
android:visibility="invisible"
android:color="#aaa" />
</RelativeLayout>
</TableRow>
</LinearLayout>
</ScrollView>
创建弹出窗口的代码
private void initiatePopupWindow(View anchor, final int pos) {
try {
popupWindow.dismiss();
} catch (Exception e) {
// TODO: handle exception
e.printStackTrace();
}
try {
//Display display = ((WindowManager) getSystemService(Context.WINDOW_SERVICE)).getDefaultDisplay();
LayoutInflater layoutInflater = (LayoutInflater) getBaseContext().getSystemService(LAYOUT_INFLATER_SERVICE);
popupView = layoutInflater.inflate(R.layout.chat_popup, null);
//popupWindow = new PopupWindow(popupView, LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT);
popupWindow = new PopupWindow(popupView, width_px, LayoutParams.WRAP_CONTENT);
//popupWindow.setBackgroundDrawable(new ColorDrawable());
//popupWindow.setFocusable(true);
//popupWindow.setOutsideTouchable(true);
profilePic = (ImageView) popupView.findViewById(R.id.profilePic);
phoneIcon = (TextView) popupView.findViewById(R.id.phoneIcon);
......
......
......
}
}