Android 基本控件PopupWindow

基本的方法:

public void showAsDropDown(View anchor) {
    throw new RuntimeException("Stub!");
}//设置相对于某个控件的正下方,无偏移

public void showAsDropDown(View anchor, int xoff, int yoff) {
    throw new RuntimeException("Stub!");
}// 设置在某个控件的下方,可以沿着Xy轴进行偏移

public void showAsDropDown(View anchor, int xoff, int yoff, int gravity) {
    throw new RuntimeException("Stub!");
}//设置popupwindow事件的位置大小等。
public void dismiss() {
    throw new RuntimeException("Stub!");
}//关闭popupwindow事件
public void setTouchable(boolean touchable) {
    throw new RuntimeException("Stub!");
}//设置触摸popupWindow内的事件

public boolean isOutsideTouchable() {
    throw new RuntimeException("Stub!");
}

public void setOutsideTouchable(boolean touchable) {
    throw new RuntimeException("Stub!");
}//设置popupwindow外的触摸事件
package com.example.test1;

import androidx.appcompat.app.AppCompatActivity;

import android.os.Bundle;
import android.util.Log;
import android.view.View;
import android.widget.Button;
import android.widget.PopupWindow;

public class MainActivity extends AppCompatActivity {

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);
    }

    public void popupOnclike(View view) {


        View popupview = getLayoutInflater().inflate(R.layout.popupview,null,true);
        Button button = popupview.findViewById(R.id.but1);

        PopupWindow popupWindow = new PopupWindow(popupview,400,400,true);
        popupWindow.showAsDropDown(view,300,300);
        button.setOnClickListener(new View.OnClickListener() {
            private static final String TAG = "led";

            @Override
            public void onClick(View view) {
                Log.e(TAG, "onClick: 哈哈哈" );
                popupWindow.dismiss();

            }
        });
    }


}

上一篇:Dubbo(RPC原理、Dubbo架构&负载均衡配置方式)(1)


下一篇:java AWT