DialogFragment를 사용하고 있는데 layout_width 및 minWidth를 고정하여 얼마나 많은 contraints를 강제하려고해도 LinearLayout의 layout_width = match_parent를 만들 때 항상 너비가 항상 전체 화면이됩니다. 상위 뷰 또는 CreateView의 레이아웃 dimens()DialogFragment 크기 (너비) 무시
설정 dialog.xml의
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="@dimen/dialog_width"
android:layout_height="@dimen/dialog_height"
android:minWidth="@dimen/dialog_width"
android:minHeight="@dimen/dialog_height"
android:orientation="vertical"
android:paddingTop="5dp">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content">
...
</LinearLayout>
</LinearLayout>
Dialog.java
public class MyDialog extends DialogFragment {
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
...
Resources r = getActivity().getResources();
getDialog().getWindow().setLayout((int)r.getDimension(R.dimen.dialog_width), (int)r.getDimension(R.dimen.dialog_height));
return view;
}
}
오 내가이 일을 할 수 있습니다 할수 있답니다 방법은 = "@ DIMEN/dialog_width
해킹 dialog.xml 괜찮 작동하지만 대화의 다른 부분에 대한 몇 가지 결과를 초래
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
... >
<LinearLayout
android:layout_width="@dimen/dialog_width"
android:layout_height="wrap_content">
...
</LinearLayout>
...
</LinearLayout>
내부의 LinearLayout의 layout_width를 설정하는 것입니다. Android에서 버그입니까?
사용 RelativeLayout의 모든 물건을 넣어 대신 선형 – Sameer