에뮬레이터에서 정상적으로 보이지만 기기에서 이상하게 보이는 Alertdialog를 생성하여 표시합니다.Android Alertdialog의 크기는 Emultator와 Device에서 서로 다릅니다.
이것은 에뮬레이터에서와 같은 모습입니다 :이 코드는
입니다 :
이것은 장치에서 같은 모습입니다 대화 상자를 표시하기 위해 실행 중입니다.
AlertDialog.Builder builder;
LayoutInflater inflater = (LayoutInflater) getSystemService(Context.LAYOUT_INFLATER_SERVICE);
View layout = inflater.inflate(R.layout.popup_contact, (ViewGroup) findViewById(R.id.ppc_llContact));
tbMissatge = (EditText) layout.findViewById(R.id.ppc_tbMissatge);
builder = new AlertDialog.Builder(this);
builder.setView(layout);
ppEnviarMsg = builder.create();
btEnviar = (Button) layout.findViewById(R.id.ppc_btEnviar);
btEnviar.setOnClickListener(this);
ppEnviarMsg.show();
ppEnviarMsg.getWindow().getAttributes().gravity = Gravity.CENTER;
그리고 여기에 팝업의 레이아웃 :
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/ppc_llContact"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:background="#414145"
android:orientation="vertical"
android:gravity="center">
<TextView
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:textColor="#ffffff"
android:text="@string/ppc_lbContact"
android:layout_margin="4dp"/>
<EditText
android:id="@+id/ppc_tbMissatge"
android:hint="@string/ppc_tooltipContact"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_margin="2dp"
android:inputType="textMultiLine"
android:gravity="top"
android:lines="5">
</EditText>
<Button android:id="@+id/ppc_btEnviar"
android:text="@string/ppc_btEnviar"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:paddingLeft="20dp"
android:paddingRight="20dp"
android:layout_marginTop="10dp"/>
</LinearLayout>
은 그것이 어쩌면 감각과 관련이있을 수 있을까요? 내 장치는 ICS 및 Sense를 실행하는 HTC Desrie S입니다. 단서가 있습니까?
도와 주셔서 감사합니다.
또한 ICS 에뮬레이터에서 실행을 시도 할 수 있습니다 :
또 다른 옵션은 강제로 대화의이 방법으로 크기를 설정하는 것입니다. 스크린 샷의 에뮬레이터는 2.3과 같이 보입니다. – Ivan
dialogfragment를 사용해보고 동작 방식을 확인하는 것이 좋습니다. – Warpzit
이미지를 편집 해 주셔서 감사합니다. 좋아, 에뮬레이터에서 ICS를 시도하고 다이얼로그를 살펴볼 것이다. 결과를 게시 할 것입니다! – weilah