久久久久久久av_日韩在线中文_看一级毛片视频_日本精品二区_成人深夜福利视频_武道仙尊动漫在线观看

    <bdo id='TkWLe'></bdo><ul id='TkWLe'></ul>
  • <i id='TkWLe'><tr id='TkWLe'><dt id='TkWLe'><q id='TkWLe'><span id='TkWLe'><b id='TkWLe'><form id='TkWLe'><ins id='TkWLe'></ins><ul id='TkWLe'></ul><sub id='TkWLe'></sub></form><legend id='TkWLe'></legend><bdo id='TkWLe'><pre id='TkWLe'><center id='TkWLe'></center></pre></bdo></b><th id='TkWLe'></th></span></q></dt></tr></i><div class="qwawimqqmiuu" id='TkWLe'><tfoot id='TkWLe'></tfoot><dl id='TkWLe'><fieldset id='TkWLe'></fieldset></dl></div>

      <small id='TkWLe'></small><noframes id='TkWLe'>

        <legend id='TkWLe'><style id='TkWLe'><dir id='TkWLe'><q id='TkWLe'></q></dir></style></legend>
      1. <tfoot id='TkWLe'></tfoot>

        使用 ImageView 顯示 AlertDialog 而無需任何填充

        Show AlertDialog with ImageView without any padding(使用 ImageView 顯示 AlertDialog 而無需任何填充)
        <i id='WYaRs'><tr id='WYaRs'><dt id='WYaRs'><q id='WYaRs'><span id='WYaRs'><b id='WYaRs'><form id='WYaRs'><ins id='WYaRs'></ins><ul id='WYaRs'></ul><sub id='WYaRs'></sub></form><legend id='WYaRs'></legend><bdo id='WYaRs'><pre id='WYaRs'><center id='WYaRs'></center></pre></bdo></b><th id='WYaRs'></th></span></q></dt></tr></i><div class="qwawimqqmiuu" id='WYaRs'><tfoot id='WYaRs'></tfoot><dl id='WYaRs'><fieldset id='WYaRs'></fieldset></dl></div>
          <bdo id='WYaRs'></bdo><ul id='WYaRs'></ul>
          • <legend id='WYaRs'><style id='WYaRs'><dir id='WYaRs'><q id='WYaRs'></q></dir></style></legend>

              <tbody id='WYaRs'></tbody>

                <small id='WYaRs'></small><noframes id='WYaRs'>

              1. <tfoot id='WYaRs'></tfoot>

                • 本文介紹了使用 ImageView 顯示 AlertDialog 而無需任何填充的處理方法,對大家解決問題具有一定的參考價值,需要的朋友們下面隨著小編來一起學習吧!

                  問題描述

                  編輯 - 解決方案:

                  我最終找到了解決此問題的方法.因為手動更改 ImageView 的高度會刪除額外的填充,所以我最終找到了原始圖像的尺寸,并在可以計算 ImageView 尺寸后將它們應用于 ImageView.這是最終結果:

                  I ended up figuring out a way to solve this issue. Because manually changing the height of the ImageView removes the extra padding, I ended up finding the dimensions of the original image, and apply them to the ImageView once the ImageView dimensions can be calculated. Here is the final result:

                  這是最終的工作代碼:

                  AlertDialog.Builder builder = new AlertDialog.Builder(this);
                          builder.setPositiveButton("Get Pro", new DialogInterface.OnClickListener() {
                              @Override
                              public void onClick(DialogInterface dialog, int which) {
                              }
                          }).setNegativeButton("No thanks", new DialogInterface.OnClickListener() {
                              @Override
                              public void onClick(DialogInterface dialog, int which) {
                              }
                          });
                          final AlertDialog dialog = builder.create();
                          LayoutInflater inflater = getLayoutInflater();
                          View dialogLayout = inflater.inflate(R.layout.go_pro_dialog_layout, null);
                          dialog.setView(dialogLayout);
                          dialog.requestWindowFeature(Window.FEATURE_NO_TITLE);
                  
                          dialog.show();
                  
                          dialog.setOnShowListener(new DialogInterface.OnShowListener() {
                              @Override
                              public void onShow(DialogInterface d) {
                                  ImageView image = (ImageView) dialog.findViewById(R.id.goProDialogImage);
                                  Bitmap icon = BitmapFactory.decodeResource(context.getResources(),
                                          R.drawable.whygoprodialogimage);
                                  float imageWidthInPX = (float)image.getWidth();
                  
                                  LinearLayout.LayoutParams layoutParams = new LinearLayout.LayoutParams(Math.round(imageWidthInPX),
                                          Math.round(imageWidthInPX * (float)icon.getHeight() / (float)icon.getWidth()));
                                  image.setLayoutParams(layoutParams);
                  
                  
                              }
                          });
                  

                  還有 XML:

                  <?xml version="1.0" encoding="utf-8"?>
                  <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
                      android:orientation="vertical"
                      android:layout_width="wrap_content"
                      android:layout_height="wrap_content">
                  
                      <ImageView
                          android:id="@+id/goProDialogImage"
                          android:layout_width="wrap_content"
                          android:layout_height="350dp"
                          android:src="@drawable/whygoprodialogimage"/>
                  
                  </LinearLayout>
                  

                  原始問題:

                  我的目標是有一個 AlertDialog ,它有一個 ImageView 占據整個對話框,保留它的尺寸,加上兩個按鈕.通過標準方法實現,如下所示:

                  My goal is to have an AlertDialog that has an ImageView that takes up the whole dialog, retaining it's dimensions, plus two buttons. By implementing it through standard methods, it looks like the following:

                  我正在嘗試消除它上方和下方的填充.下面是它的設置代碼:

                  I am trying to eliminate that padding above and below it. Here's the code for how it's set up:

                  布局:

                  <?xml version="1.0" encoding="utf-8"?>
                  <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
                      android:orientation="vertical"
                      android:layout_width="match_parent"
                      android:layout_height="wrap_content">
                  
                      <ImageView
                          android:id="@+id/goProDialogImage"
                          android:layout_width="match_parent"
                          android:layout_height="wrap_content"
                          android:src="@drawable/whygoprodialogimage"/>
                  
                  </LinearLayout>
                  

                  代碼:

                  AlertDialog.Builder builder = new AlertDialog.Builder(this);
                          builder.setPositiveButton("Get Pro", new DialogInterface.OnClickListener() {
                              @Override
                              public void onClick(DialogInterface dialog, int which) {
                              }
                          }).setNegativeButton("No thanks", new DialogInterface.OnClickListener() {
                              @Override
                              public void onClick(DialogInterface dialog, int which) {
                              }
                          });
                          AlertDialog dialog = builder.create();
                          LayoutInflater inflater = getLayoutInflater();
                          View dialogLayout = inflater.inflate(R.layout.go_pro_dialog_layout, null);
                          dialog.setView(dialogLayout);
                          dialog.requestWindowFeature(Window.FEATURE_NO_TITLE);
                  
                          dialog.show();
                  

                  查看this StackOverflow answer后,我嘗試實施該解決方案,因為他們的問題似乎相似,但即使它是更接近我現在想要的結果如下所示:

                  After looking at this StackOverflow answer, I tried implementing that solution because their problem seemed similar, but even though it is closer to what I want now the result looks like this:

                  所以它消除了填充,但圖像看起來被壓扁了.這是此潛在修復實現的代碼:

                  So it eliminated the padding but the image looks squished. Here's the code for this potential fix implementation:

                  // Get screen size
                          Display display = getWindowManager().getDefaultDisplay();
                          Point size = new Point();
                          display.getSize(size);
                          int screenWidth = size.x;
                          int screenHeight = size.y;
                  
                          // Get target image size
                          Bitmap bitmap = BitmapFactory.decodeResource(getResources(), R.drawable.whygoprodialogimage);
                          int bitmapHeight = bitmap.getHeight();
                          int bitmapWidth = bitmap.getWidth();
                  
                          // Scale the image down to fit perfectly into the screen
                          // The value (250 in this case) must be adjusted for phone/tables displays
                          while(bitmapHeight > (screenHeight - 250) || bitmapWidth > (screenWidth - 250)) {
                              bitmapHeight = bitmapHeight / 2;
                              bitmapWidth = bitmapWidth / 2;
                          }
                  
                          // Create resized bitmap image
                          BitmapDrawable resizedDialogImage = new BitmapDrawable(context.getResources(), Bitmap.createScaledBitmap(bitmap, bitmapWidth, bitmapHeight, false));
                  
                          AlertDialog.Builder builder = new AlertDialog.Builder(this);
                          builder.setPositiveButton("Get Pro", new DialogInterface.OnClickListener() {
                              @Override
                              public void onClick(DialogInterface dialog, int which) {
                  
                              }
                          }).setNegativeButton("No thanks", new DialogInterface.OnClickListener() {
                              @Override
                              public void onClick(DialogInterface dialog, int which) {
                              }
                          });
                          AlertDialog dialog = builder.create();
                          LayoutInflater inflater = getLayoutInflater();
                          View dialogLayout = inflater.inflate(R.layout.go_pro_dialog_layout, null);
                          dialog.setView(dialogLayout);
                          dialog.requestWindowFeature(Window.FEATURE_NO_TITLE);
                  
                          // Without this line there is a very small border around the image (1px)
                          dialog.getWindow().setBackgroundDrawable(null);
                  
                          dialog.show();
                          ImageView image = (ImageView) dialog.findViewById(R.id.goProDialogImage);
                          image.setBackground(resizedDialogImage);
                  

                  是什么導致圖像現在看起來被壓扁了?你可以看出它去掉了額外的填充,但圖像尺寸發生了變化.

                  What is it that is causing the image to now look squished? You can tell it got rid of the extra padding but the image dimensions are changed.

                  推薦答案

                  我最終找到了解決這個問題的方法.因為手動更改 ImageView 的高度會刪除額外的填充,所以我最終找到了原始圖像的尺寸,并在可以計算 ImageView 尺寸后將它們應用于 ImageView.這是最終結果:

                  I ended up figuring out a way to solve this issue. Because manually changing the height of the ImageView removes the extra padding, I ended up finding the dimensions of the original image, and apply them to the ImageView once the ImageView dimensions can be calculated. Here is the final result:

                  這是最終的工作代碼:

                  AlertDialog.Builder builder = new AlertDialog.Builder(this);
                          builder.setPositiveButton("Get Pro", new DialogInterface.OnClickListener() {
                              @Override
                              public void onClick(DialogInterface dialog, int which) {
                              }
                          }).setNegativeButton("No thanks", new DialogInterface.OnClickListener() {
                              @Override
                              public void onClick(DialogInterface dialog, int which) {
                              }
                          });
                          final AlertDialog dialog = builder.create();
                          LayoutInflater inflater = getLayoutInflater();
                          View dialogLayout = inflater.inflate(R.layout.go_pro_dialog_layout, null);
                          dialog.setView(dialogLayout);
                          dialog.requestWindowFeature(Window.FEATURE_NO_TITLE);
                  
                          dialog.show();
                  
                          dialog.setOnShowListener(new DialogInterface.OnShowListener() {
                              @Override
                              public void onShow(DialogInterface d) {
                                  ImageView image = (ImageView) dialog.findViewById(R.id.goProDialogImage);
                                  Bitmap icon = BitmapFactory.decodeResource(context.getResources(),
                                          R.drawable.whygoprodialogimage);
                                  float imageWidthInPX = (float)image.getWidth();
                  
                                  LinearLayout.LayoutParams layoutParams = new LinearLayout.LayoutParams(Math.round(imageWidthInPX),
                                          Math.round(imageWidthInPX * (float)icon.getHeight() / (float)icon.getWidth()));
                                  image.setLayoutParams(layoutParams);
                  
                  
                              }
                          });
                  

                  還有 XML:

                  <?xml version="1.0" encoding="utf-8"?>
                  <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
                      android:orientation="vertical"
                      android:layout_width="wrap_content"
                      android:layout_height="wrap_content">
                  
                      <ImageView
                          android:id="@+id/goProDialogImage"
                          android:layout_width="wrap_content"
                          android:layout_height="350dp"
                          android:src="@drawable/whygoprodialogimage"/>
                  
                  </LinearLayout>
                  

                  這篇關于使用 ImageView 顯示 AlertDialog 而無需任何填充的文章就介紹到這了,希望我們推薦的答案對大家有所幫助,也希望大家多多支持html5模板網!

                  【網站聲明】本站部分內容來源于互聯網,旨在幫助大家更快的解決問題,如果有圖片或者內容侵犯了您的權益,請聯系我們刪除處理,感謝您的支持!

                  相關文檔推薦

                  Get user#39;s current location using GPS(使用 GPS 獲取用戶的當前位置)
                  IllegalArgumentException thrown by requestLocationUpdate()(requestLocationUpdate() 拋出的 IllegalArgumentException)
                  How reliable is LocationManager#39;s getLastKnownLocation and how often is it updated?(LocationManager 的 getLastKnownLocation 有多可靠,多久更新一次?)
                  How to detect Location Provider ? GPS or Network Provider(如何檢測位置提供者?GPS 或網絡提供商)
                  Get current location during app launch(在應用啟動期間獲取當前位置)
                  locationManager.getLastKnownLocation() return null(locationManager.getLastKnownLocation() 返回 null)

                  <legend id='bEWve'><style id='bEWve'><dir id='bEWve'><q id='bEWve'></q></dir></style></legend>
                    <tbody id='bEWve'></tbody>
                    <i id='bEWve'><tr id='bEWve'><dt id='bEWve'><q id='bEWve'><span id='bEWve'><b id='bEWve'><form id='bEWve'><ins id='bEWve'></ins><ul id='bEWve'></ul><sub id='bEWve'></sub></form><legend id='bEWve'></legend><bdo id='bEWve'><pre id='bEWve'><center id='bEWve'></center></pre></bdo></b><th id='bEWve'></th></span></q></dt></tr></i><div class="qwawimqqmiuu" id='bEWve'><tfoot id='bEWve'></tfoot><dl id='bEWve'><fieldset id='bEWve'></fieldset></dl></div>

                    <tfoot id='bEWve'></tfoot>

                    <small id='bEWve'></small><noframes id='bEWve'>

                      <bdo id='bEWve'></bdo><ul id='bEWve'></ul>

                            主站蜘蛛池模板: 久久久高清 | 国产目拍亚洲精品99久久精品 | 日韩一 | 日韩精品一区二区在线 | 一区二区三区四区国产 | 深夜福利亚洲 | 久久精品一区二区三区四区 | 欧美日韩国产在线观看 | 久久国产一区二区 | 亚洲一区电影 | 日本免费一区二区三区四区 | 日韩中文字幕一区 | 在线播放国产一区二区三区 | 日本黄色激情视频 | 日本久久网 | 国产精品久久久久久久午夜片 | 在线视频一区二区 | 国产精品久久国产精品 | 日本欧美在线观看视频 | 91极品尤物在线播放国产 | www日本在线播放 | 亚洲精品中文在线观看 | 亚洲国产精品99久久久久久久久 | 国产精品美女久久久久久免费 | 久久亚洲国产 | 成人午夜免费在线视频 | 91婷婷韩国欧美一区二区 | 99久久婷婷国产精品综合 | 91精品国产综合久久香蕉922 | 国产精品成人国产乱一区 | 国产网站在线播放 | 91免费看片 | 久久国产精品一区二区三区 | 亚洲欧美成人 | 日韩免费视频一区二区 | 免费视频一区 | 欧美中文在线 | 久久综合九九 | 国产精品三级 | 亚洲性视频在线 | 精品久久国产 |