[英]How to set the height of popup window in android Java
[![enter image description here][1]][1] [![在此处输入图像描述][1]][1]
Hi, How can achieve the above image.你好,如何实现上面的图像。 when user clicks on the profile icon then the pop up window will display.当用户单击配置文件图标时,将显示弹出窗口。 But here the problem i am getting is pop up window is covering the whole height from anchor view.但在这里我遇到的问题是弹出窗口覆盖了锚视图的整个高度。 I need to show that home and barcode images bottom navigation view.我需要显示主页和条形码图像底部导航视图。
My XML Code我的 XML 代码
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout
xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="@drawable/menu">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical">
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Menu"
android:textSize="30sp"
android:layout_marginBottom="60dp"
android:layout_gravity="center"
android:layout_marginStart="10dp"
android:layout_marginEnd="10dp"
android:gravity="center"
android:fontFamily="@font/robotobold"
android:layout_marginTop="20dp"
android:textColor="@color/colorBlack">
</TextView>
<TextView
android:id="@+id/agent"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Agent Agreement"
android:layout_margin="10dp"
android:textSize="14sp"
android:layout_gravity="start"
android:gravity="start"
android:fontFamily="@font/robotobold"
android:textColor="@color/colorBlack">
</TextView>
<TextView
android:id="@+id/privacypolicy"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Privacy Policy"
android:layout_margin="10dp"
android:textSize="14sp"
android:layout_gravity="start"
android:gravity="start"
android:fontFamily="@font/robotobold"
android:textColor="@color/colorBlack">
</TextView>
<TextView
android:id="@+id/changesettings"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="How to change your settings"
android:layout_margin="10dp"
android:textSize="14sp"
android:layout_gravity="start"
android:gravity="start"
android:fontFamily="@font/robotobold"
android:textColor="@color/colorBlack">
</TextView>
<TextView
android:id="@+id/bankinfo"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Your Bank Account Info"
android:layout_margin="10dp"
android:textSize="14sp"
android:layout_gravity="start"
android:gravity="start"
android:fontFamily="@font/robotobold"
android:textColor="@color/colorBlack">
</TextView>
<TextView
android:id="@+id/profilepic"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Profile Picture"
android:layout_margin="10dp"
android:textSize="14sp"
android:layout_gravity="start"
android:gravity="start"
android:fontFamily="@font/robotobold"
android:textColor="@color/colorBlack">
</TextView>
<TextView
android:id="@+id/logout"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Logout"
android:layout_margin="10dp"
android:textSize="14sp"
android:layout_gravity="start"
android:gravity="start"
android:fontFamily="@font/robotobold"
android:textColor="@color/colorBlack">
</TextView>
</LinearLayout>
</RelativeLayout>
and Java code for displaying pop window和用于显示弹出窗口的 Java 代码
draweeView3.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
showPopup(view) ;
}
});
private void showPopup(View view) {
View popupView = getLayoutInflater().inflate(R.layout.menupopup, null);
popupWindow.setFocusable(true);
PopupWindow popupWindow = new PopupWindow(popupView,
ViewGroup.LayoutParams.WRAP_CONTENT, ViewGroup.LayoutParams.WRAP_CONTENT);
TextView tv = (TextView) popupView.findViewById(R.id.lesshigh);
popupWindow.showAsDropDown(view,-25, 10);
}
Change the values of android:layout_height
in your LinearLayout
.更改LinearLayout
中android:layout_height
的值。 For me the best what can you do will be look like this :对我来说,你能做的最好的事情是这样的:
...
<LinearLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:orientation="vertical">
...
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.