Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

在DialogFragment中没有适配成功(在tv和手机上),项目固定为横屏 #83

Closed
huanyuan opened this issue Nov 8, 2018 · 4 comments

Comments

@huanyuan
Copy link

huanyuan commented Nov 8, 2018

public class BackDialogFragment extends DialogFragment implements CustomAdapt {
@BindView(R.id.quit_iv) ImageView quitIv;
@BindView(R.id.quit_msg_tv) TextView quitMsgTv;
@BindView(R.id.quit_yes)
Button quitYes;
@BindView(R.id.quit_no) Button quitNo;

@Override
public boolean isBaseOnWidth() {
    return true;
}

@Override
public float getSizeInDp() {
    return 1920;
}

class OkListener implements OnClickListener {
    OkListener() {
    }
    @Override
    public void onClick(View view) {
        dismiss();
        getActivity().finish();
    }
}

class CancelListener implements OnClickListener {
    CancelListener() {
    }
    @Override
    public void onClick(View view) {
        dismiss();
    }
}

public static BackDialogFragment getBackDialogFragment() {
        Bundle bundle = new Bundle();
        BackDialogFragment  mbackDialogFragment = new BackDialogFragment();
        mbackDialogFragment.setArguments(bundle);
    return mbackDialogFragment;
}

@Override
public View onCreateView(LayoutInflater layoutInflater, ViewGroup viewGroup, Bundle bundle) {
    View inflate = layoutInflater.inflate(R.layout.dialog_fragment_quit, viewGroup);
    ButterKnife.bind(this,inflate);
    initListener();

// AutoSize.autoConvertDensity(getActivity(), 1920, true);
AutoSizeConfig.getInstance().setCustomFragment(true);
return inflate;
}

@Override
public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
}


private void initListener() {
    quitYes.setOnClickListener(new OkListener());
    quitNo.setOnClickListener(new CancelListener());
    quitNo.requestFocus();
}

@Override
public void onDestroy() {
    super.onDestroy();
}

}

布局用的是dp

@huanyuan
Copy link
Author

huanyuan commented Nov 8, 2018

qq 20181108102945
screenshot

@huanyuan
Copy link
Author

huanyuan commented Nov 8, 2018

qq 20181108103416

@JessYanCoding
Copy link
Owner

#13

@mxdlsm
Copy link

mxdlsm commented Dec 19, 2023

public class BackDialogFragment extends DialogFragment implements CustomAdapt { @BindView(R.id.quit_iv) ImageView quitIv; @BindView(R.id.quit_msg_tv) TextView quitMsgTv; @BindView(R.id.quit_yes) Button quitYes; @BindView(R.id.quit_no) Button quitNo;

@Override
public boolean isBaseOnWidth() {
    return true;
}

@Override
public float getSizeInDp() {
    return 1920;
}

class OkListener implements OnClickListener {
    OkListener() {
    }
    @Override
    public void onClick(View view) {
        dismiss();
        getActivity().finish();
    }
}

class CancelListener implements OnClickListener {
    CancelListener() {
    }
    @Override
    public void onClick(View view) {
        dismiss();
    }
}

public static BackDialogFragment getBackDialogFragment() {
        Bundle bundle = new Bundle();
        BackDialogFragment  mbackDialogFragment = new BackDialogFragment();
        mbackDialogFragment.setArguments(bundle);
    return mbackDialogFragment;
}

@Override
public View onCreateView(LayoutInflater layoutInflater, ViewGroup viewGroup, Bundle bundle) {
    View inflate = layoutInflater.inflate(R.layout.dialog_fragment_quit, viewGroup);
    ButterKnife.bind(this,inflate);
    initListener();

// AutoSize.autoConvertDensity(getActivity(), 1920, true); AutoSizeConfig.getInstance().setCustomFragment(true); return inflate; }

@Override
public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
}


private void initListener() {
    quitYes.setOnClickListener(new OkListener());
    quitNo.setOnClickListener(new CancelListener());
    quitNo.requestFocus();
}

@Override
public void onDestroy() {
    super.onDestroy();
}

}

布局用的是dp

大佬您怎么解决的呀?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants