簡體   English   中英

聚焦時如何縮放EditText?

[英]How to zoom on a EditText when focus?

我有一個ScrollView包含一個CustomView。 在那個CustomView中,我可以有許多這樣的EditText:

第一

當我聚焦一個EditText時,我想要縮放此EditText,以便此EditText位於屏幕的中央,並采用與屏幕相同的寬度。

預期結果:

在此處輸入圖片說明

對不起,我的英語不好,謝謝您的幫助!

EditText具有setOnFocusChangeListener ,用於查看EditText何時接收和釋放焦點。

     editText.setOnFocusChangeListener(new OnFocusChangeListener() {
     @Override
     public void onFocusChange(View view, boolean hasFocus) {
          if (hasFocus) {
              //Dynamically resize EditText to match device width
          } else {
              //Dynamically resize EditText to match previous width with margin
          }
      }
  });

您可以使用LayoutParams動態更改EditText的寬度和高度,如該鏈接所示

暫無
暫無

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

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