我創建並顯示了一個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>
難道可能與意識有關?我的設備是HTC Desrie S,運行ICS和Sense。 有沒有人有線索?
感謝您的幫助!
你可能也想嘗試在ICS模擬器中運行它。屏幕截圖中的模擬器看起來像2.3之前的東西.. – Ivan
我建議你嘗試一個對話框片段,看看它的行爲。 – Warpzit
感謝您編輯圖像。好吧,我會在模擬器中嘗試ICS,並且還會查看對話框片段。 我會發布結果! – weilah