pbootcms网站模板|日韩1区2区|织梦模板||网站源码|日韩1区2区|jquery建站特效-html5模板网

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

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

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

      <tfoot id='rb8Cq'></tfoot>

        Android Image Dialog/Popup 與圖像大小相同且無邊框

        Android Image Dialog/Popup same size as image and no border(Android Image Dialog/Popup 與圖像大小相同且無邊框)
            • <bdo id='anmrv'></bdo><ul id='anmrv'></ul>

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

                <tfoot id='anmrv'></tfoot>
                  <tbody id='anmrv'></tbody>

                <legend id='anmrv'><style id='anmrv'><dir id='anmrv'><q id='anmrv'></q></dir></style></legend>

                • <small id='anmrv'></small><noframes id='anmrv'>

                  本文介紹了Android Image Dialog/Popup 與圖像大小相同且無邊框的處理方法,對大家解決問題具有一定的參考價值,需要的朋友們下面隨著小編來一起學習吧!

                  問題描述

                  目前我正在使用文件瀏覽器.一切正常,但有一個例外:如果用戶單擊圖像(jpg,png,bmp,..),我希望圖像顯示在與圖像大小相同的對話框或彈出窗口中 - 這樣就沒有邊框了.圖像文件位于 sdcard 上.

                  At the moment I am working on a file browser. Everything works fine with one exception: If the user clicks on an image (jpg, png, bmp, ..), I want the image to be displayed in a dialog or in a popup which has the same size as the image - so that there are no borders at all. The image files are located on the sdcard.

                  這是我目前所擁有的:

                  BitmapDrawable bitmap = new BitmapDrawable(context.getResources(), TARGET_PATH);
                  
                  AlertDialog.Builder imageDialog = new AlertDialog.Builder(context);
                  LayoutInflater inflater = (LayoutInflater) context.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
                  
                  View layout = inflater.inflate(R.layout.thumbnail, null);
                  ImageView image = (ImageView) layout.findViewById(R.id.thumbnail_IMAGEVIEW);
                  image.setImageDrawable(bitmap);
                  imageDialog.setView(layout);
                  imageDialog.create();
                  imageDialog.show();
                  

                  XML 文件:

                  <?xml version="1.0" encoding="utf-8"?>
                  <RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
                      android:layout_width="match_parent"
                      android:layout_height="match_parent" >
                  
                      <ImageView
                          android:id="@+id/thumbnail_IMAGEVIEW"
                          android:layout_width="wrap_content"
                          android:layout_height="wrap_content"
                          android:layout_alignParentLeft="true"
                          android:layout_alignParentTop="true"
                          android:contentDescription="@string/icon_DESCRIPTION" />
                  
                  </RelativeLayout>
                  

                  這是輸出:

                  圖像邊緣有丑陋的邊框 - 我不希望它們顯示出來.我嘗試了很多在 google 等中列出的東西和示例. - 還沒有任何效果.

                  There are ugly borders at the edges of the images - I don't want them to be shown. I tried lots of stuff and examples listed in google, etc.. - nothing worked yet.

                  最好的選擇是使圖像后面的對話框/視圖與圖像大小相同.另一種方法是將圖像背后的背景設(shè)置為透明.

                  The best option will be to make the dialog/the view behind the image, the same size as the image. Another way could be to set the background behind the image transparent.

                  如何實現(xiàn)任何解決方案?我想讓背景與圖像的大小相同,因此不會留下不可見"的東西,但我也可以使用透明選項.

                  How do I achieve any solution? I'd love to make the background the same size as the image is, so there is no "invisible" stuff left, but I will also be okay with the transparent option.

                  解決方案:

                  // Get screen size
                  Display display = context.getWindowManager().getDefaultDisplay();
                  Point size = new Point();
                  display.getSize(size);
                  int screenWidth = size.x;
                  int screenHeight = size.y;
                  
                  // Get target image size
                  Bitmap bitmap = BitmapFactory.decodeFile(TARGET);
                  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 resizedBitmap = new BitmapDrawable(context.getResources(), Bitmap.createScaledBitmap(bitmap, bitmapWidth, bitmapHeight, false));
                  
                  // Create dialog
                  Dialog dialog = new Dialog(context);
                  dialog.requestWindowFeature(Window.FEATURE_NO_TITLE);
                  dialog.setContentView(R.layout.thumbnail);
                  
                  ImageView image = (ImageView) dialog.findViewById(R.id.imageview);
                  
                  // !!! Do here setBackground() instead of setImageDrawable() !!! //
                  image.setBackground(resizedBitmap);
                  
                  // Without this line there is a very small border around the image (1px)
                  // In my opinion it looks much better without it, so the choice is up to you.
                  dialog.getWindow().setBackgroundDrawable(null);
                  
                  // Show the dialog
                  dialog.show();
                  

                  XML 文件:

                  <?xml version="1.0" encoding="utf-8"?>
                  <ImageView xmlns:android="http://schemas.android.com/apk/res/android"
                      android:id="@+id/imageview"
                      android:layout_width="match_parent"
                      android:layout_height="match_parent" >
                  
                  </ImageView>
                  

                  最終輸出:

                  推薦答案

                  從這里改變你的 ImageView:

                  Change your ImageView from this:

                  <ImageView
                          android:id="@+id/thumbnail_IMAGEVIEW"
                          android:layout_width="wrap_content"
                          android:layout_height="wrap_content"
                          android:layout_alignParentLeft="true"
                          android:layout_alignParentTop="true"
                          android:contentDescription="@string/icon_DESCRIPTION" />
                  

                  到這里:

                  <ImageView
                          android:id="@+id/thumbnail_IMAGEVIEW"
                          android:layout_width="wrap_content"
                          android:layout_height="wrap_content"
                          android:layout_alignParentLeft="true"
                          android:layout_alignParentTop="true"
                          android:adjustViewBounds="true" <!-- Here is the thing -->
                          android:contentDescription="@string/icon_DESCRIPTION" />
                  

                  希望這會有所幫助.

                  這篇關(guān)于Android Image Dialog/Popup 與圖像大小相同且無邊框的文章就介紹到這了,希望我們推薦的答案對大家有所幫助,也希望大家多多支持html5模板網(wǎng)!

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

                  相關(guān)文檔推薦

                  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 或網(wǎng)絡(luò)提供商)
                  Get current location during app launch(在應(yīng)用啟動期間獲取當前位置)
                  locationManager.getLastKnownLocation() return null(locationManager.getLastKnownLocation() 返回 null)
                    <tfoot id='mw4oG'></tfoot>
                  • <legend id='mw4oG'><style id='mw4oG'><dir id='mw4oG'><q id='mw4oG'></q></dir></style></legend>
                      <bdo id='mw4oG'></bdo><ul id='mw4oG'></ul>

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

                            <tbody id='mw4oG'></tbody>
                        • <small id='mw4oG'></small><noframes id='mw4oG'>

                            主站蜘蛛池模板: 高清视频编码器,4K音视频编解码器,直播编码器,流媒体服务器,深圳海威视讯技术有限公司 | 广州企亚 - 数码直喷、白墨印花、源头厂家、透气无手感方案服务商! | 中式装修设计_全屋定制家具_实木仿古门窗花格厂家-喜迎门 | 拉伸膜,PE缠绕膜,打包带,封箱胶带,包装膜厂家-东莞宏展包装 | 喷播机厂家_二手喷播机租赁_水泥浆洒布机-河南青山绿水机电设备有限公司 | YAGEO国巨电容|贴片电阻|电容价格|三星代理商-深圳市巨优电子有限公司 | 黑龙江「京科脑康」医院-哈尔滨失眠医院_哈尔滨治疗抑郁症医院_哈尔滨精神心理医院 | 水平垂直燃烧试验仪-灼热丝试验仪-漏电起痕试验仪-针焰试验仪-塑料材料燃烧检测设备-IP防水试验机 | 不锈钢丸厂家,铝丸,铸钢丸-淄博智源铸造材料有限公司 | 间甲酚,间甲酚厂家-山东祥东新材料 | 炭黑吸油计_测试仪,单颗粒子硬度仪_ASTM标准炭黑自销-上海贺纳斯仪器仪表有限公司(HITEC中国办事处) | 钢化玻璃膜|手机钢化膜|钢化膜厂家|手机保护膜-【东莞市大象电子科技有限公司】 | 下水道疏通_管道疏通_马桶疏通_附近疏通电话- 立刻通 | 美甲贴片-指甲贴片-穿戴美甲-假指甲厂家--薇丝黛拉 | 对辊破碎机-液压双辊式,强力双齿辊,四辊破碎机价格_巩义市金联机械设备生产厂家 | 球磨机 选矿球磨机 棒磨机 浮选机 分级机 选矿设备厂家 | 双吸泵,双吸泵厂家,OS双吸泵-山东博二泵业有限公司 | 火锅加盟_四川成都火锅店加盟_中国火锅连锁品牌十强_朝天门火锅【官网】 | 企小优-企业数字化转型服务商_网络推广_网络推广公司 | 大型工业风扇_工业大风扇_大吊扇_厂房车间降温-合昌大风扇 | 商用绞肉机-熟肉切片机-冻肉切丁机-猪肉开条机 - 广州市正盈机械设备有限公司 | 400电话_400电话申请_866元/年_【400电话官方业务办理】-俏号网 3dmax渲染-效果图渲染-影视动画渲染-北京快渲科技有限公司 | 置顶式搅拌器-优莱博化学防爆冰箱-磁驱搅拌器-天津市布鲁克科技有限公司 | 真空泵维修保养,普发,阿尔卡特,荏原,卡西亚玛,莱宝,爱德华干式螺杆真空泵维修-东莞比其尔真空机电设备有限公司 | 烟台游艇培训,威海游艇培训-烟台市邮轮游艇行业协会 | 内窥镜-工业内窥镜厂家【上海修远仪器仪表有限公司】 | 非标压力容器_碳钢储罐_不锈钢_搪玻璃反应釜厂家-山东首丰智能环保装备有限公司 | 微水泥_硅藻泥_艺术涂料_艺术漆_艺术漆加盟-青岛泥之韵环保壁材 武汉EPS线条_EPS装饰线条_EPS构件_湖北博欧EPS线条厂家 | 层流手术室净化装修-检验科ICU改造施工-华锐净化工程-特殊科室建设厂家 | 金属管浮子流量计_金属转子流量计厂家-淮安润中仪表科技有限公司 | 室内室外厚型|超薄型|非膨胀型钢结构防火涂料_隧道专用防火涂料厂家|电话|价格|批发|施工 | 福建自考_福建自学考试网| 小威小说网 - 新小威小说网 - 小威小说网小说搜索引擎 | 立式_复合式_壁挂式智能化电伴热洗眼器-上海达傲洗眼器生产厂家 理化生实验室设备,吊装实验室设备,顶装实验室设备,实验室成套设备厂家,校园功能室设备,智慧书法教室方案 - 东莞市惠森教学设备有限公司 | 海尔生物医疗四川代理商,海尔低温冰箱四川销售-成都壹科医疗器械有限公司 | LED太阳能中国结|发光红灯笼|灯杆造型灯|节日灯|太阳能灯笼|LED路灯杆装饰造型灯-北京中海轩光电 | 中天寰创-内蒙古钢结构厂家|门式刚架|钢结构桁架|钢结构框架|包头钢结构煤棚 | 红立方品牌应急包/急救包加盟,小成本好项目代理_应急/消防/户外用品加盟_应急好项目加盟_新奇特项目招商 - 中红方宁(北京) 供应链有限公司 | 湖南自考_湖南自学考试 | 【星耀裂变】_企微SCRM_任务宝_视频号分销裂变_企业微信裂变增长_私域流量_裂变营销 | 气胀轴|气涨轴|安全夹头|安全卡盘|伺服纠偏系统厂家-天机传动 |