簡體   English   中英

當我在其上鍵入時,EditText會變大

[英]EditText gets bigger when I type on it

我正在開發一個Android 3.1平板電腦應用程序,但EditText控件存在“問題”。

這是一個不帶文本的EditText:

在此處輸入圖片說明

但是,當我在上面輸入一些文本時:

在此處輸入圖片說明

這四行是通過編程創建的:

    LinearLayout layout = null;
    LayoutParams layoutParams = null;
    EditText editText = null;
    RadioGroup rGroup = null;
    RadioButton rButton = null;
    String tag = null;

    layout = new LinearLayout(mActivity);
    layoutParams = 
            new LayoutParams(LayoutParams.FILL_PARENT, 60);
    layout.setOrientation(LinearLayout.HORIZONTAL);
    layout.setLayoutParams(layoutParams);

    editText = new EditText(mActivity);
    tag = Long.toString(eOtherChks.getEreportOthChkId()) + "_" + OTHER_DESCRIPTION_COL;
    editText.setTag(tag);
    layoutParams = new LayoutParams(LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT);
    layoutParams.weight = .25f;
    editText.setLayoutParams(layoutParams);
    editText.setGravity(Gravity.CENTER);
    editText.setText(eOtherChks.getDescription());
    layout.addView(editText);

但是,在另一種觀點中,我以編程方式使用editText.setInputType(InputType.TYPE_CLASS_NUMBER);添加了一些EditText editText.setInputType(InputType.TYPE_CLASS_NUMBER); 而且它們不會變大。

如何避免這種影響?

您可以嘗試設置:

layoutParams.width = 0;

這應該防止調整大小。 讓我知道它是否有效。

這就是我解決問題的方式:

layoutParams = new LayoutParams(0, LayoutParams.WRAP_CONTENT);

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM