size 相关问题

计算中的大小可以指各种维度:以位为单位的大小,以字节为单位,以像素为单位,在内存中,在磁盘空间中等。请不要在帖子中使用此标记 - 它太通用,无法对您的问题进行有用的分类。

android:layout_height屏幕尺寸的50%

i刚刚在线安排中实现了一个listView,但是我需要定义线条的高度(必须是屏幕高度的50%)。 <LinearLayout android:id="@+id/widget34" android:layout_width="300px" android:layout_height="235px" android:orientation="vertical" android:layout_below="@+id/tv_scanning_for" android:layout_centerHorizontal="true"> <ListView android:id="@+id/lv_events" android:textSize="18sp" android:cacheColorHint="#00000000" android:layout_width="fill_parent" android:layout_height="wrap_content" android:layout_below="@+id/tv_scanning_for" android:layout_centerHorizontal="true"> </ListView> </LinearLayout> 这可能吗? 我为按钮和一个诚意做了类似的事情,但似乎在布局上不起作用。 这是我的代码: //capture the size of the devices screen Display display = getWindowManager().getDefaultDisplay(); double width = display.getWidth(); //my EditText will be smaller than full screen (80%) double doubleSize = (width/5)*4; int editTextSize = (int) doubleSize; //define the EditText userName = (EditText) this.findViewById(R.id.userName); password = (EditText) this.findViewById(R.id.password); //set the size userName.setWidth(editTextSize); password.setWidth(editTextSize); 设置其layout_height="0dp"*,在其下方添加一个空白(或空白View或仅是AImageView),也等于FrameLayout,并将两个视图设置为具有 在填充屏幕时,此视图将平均伸展。由于两者都有相同的重量,因此每个都将占据屏幕的50%。 *请参阅Adamp的评论,以了解为什么它有效和其他真正有用的琐事。 在XML中很容易做到这一点。将您的顶部容器设置为线性层状,并根据需要设置方向属性。然后在那个位置的两个线安排,两者都在宽度和高度上都具有“填充父”。最后,将这两个线性延迟的Weigth属性设置为1. 这是我的android:layout_height = 50% 活动: layout_height 风格: 0dp 最佳方法是使用 layout_height=“ 0dp” layout_weight =“ 0.5” 例如 layout_weight="1" WebView,TextView具有屏幕高度的50% 为了确保视图的高度是屏幕的50%,然后我们可以在线层中创建两个子线层。每个孩子线度延迟都应具有“ anandroid:layout_weight”0.5,以覆盖一半的屏幕 父linearlayout应该具有“android:entrientation”设置为术 . . 这里是您的参考代码。 此代码包含两个高度按钮屏幕一半 <?xml version="1.0" encoding="utf-8"?> <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="fill_parent" android:layout_height="fill_parent" android:orientation="vertical" > <LinearLayout android:id="@+id/alipay_login" style="@style/loginType" android:background="#27b" > </LinearLayout> <LinearLayout android:id="@+id/taobao_login" style="@style/loginType" android:background="#ed6d00" > </LinearLayout> </LinearLayout> 这种对我有用。 虽然Fab并非独立漂浮,但现在并没有被压低。 练习linearlayout内的权重 <style name="loginType"> <item name="android:layout_width">match_parent</item> <item name="android:layout_height">match_parent</item> <item name="android:layout_weight">0.5</item> <item name="android:orientation">vertical</item> </style> 希望这有帮助:) 您应该做这样的事情: <WebView android:id="@+id/wvHelp" android:layout_width="match_parent" android:layout_height="0dp" android:layout_weight="0.5" /> <TextView android:id="@+id/txtTEMP" android:layout_width="match_parent" android:layout_height="0dp" android:layout_weight="0.5" android:text="TextView" /> 同样,也使用DP代替Px或阅读有关它Here的。 如果您想垂直将屏幕划分两个部分(TOP30% +底部70%),这很容易 <LinearLayout android:orientation="vertical" android:layout_height="match_parent"> <LinearLayout android:layout_weight="0.5" android:layout_width="fill_parent" android:layout_height="wrap_content" android:orientation="horizontal"> <Button android:padding="10dp" android:layout_weight="0.5" android:layout_width="wrap_content" android:layout_height="fill_parent" android:text="button1" android:id="@+id/button1" android:layout_alignParentTop="true" android:layout_alignParentLeft="true" android:layout_alignParentStart="true" android:layout_alignParentBottom="true" /> <Button android:padding="10dp" android:layout_weight="0.5" android:layout_width="wrap_content" android:layout_height="fill_parent" android:text="button2" android:id="@+id/button2" android:layout_alignParentTop="true" android:layout_alignParentRight="true" android:layout_alignParentEnd="true" android:layout_alignParentBottom="true" /> </LinearLayout> <LinearLayout android:layout_weight="0.5" android:layout_width="fill_parent" android:layout_height="wrap_content" android:orientation="horizontal"> </LinearLayout> </LinearLayout> 要实现这一壮举,定义了用<LinearLayout android:layout_width="match_parent" android:layout_height="wrap_content" android:orientation="vertical" android:id="@+id/andsanddkasd"> <android.support.v7.widget.RecyclerView android:id="@+id/sharedResourcesRecyclerView" android:layout_width="match_parent" android:layout_height="0dp" android:layout_weight="4" /> <android.support.design.widget.FloatingActionButton android:id="@+id/fab" android:layout_width="wrap_content" android:layout_height="0dp" android:layout_gravity="bottom|right" android:src="@android:drawable/ic_input_add" android:layout_weight="1"/> </LinearLayout> 的外部线性布局。 它定义最大重量总和。如果未指定,则总和是通过添加所有孩子的layout_weight来计算总和。例如,可以通过给出一个0.5的layout_weight并将权重设置为1.0,从而给出一个可用空间的单个孩子的50%。另一个示例将设置为重量= 2,如果两个孩子设置了<LinearLayout android:id="@+id/widget34" android:layout_width="fill_parent" android:layout_height="fill_parent" android:orientation="vertical" android:layout_below="@+id/tv_scanning_for" android:layout_centerHorizontal="true"> <ListView android:id="@+id/lv_events" android:textSize="18sp" android:cacheColorHint="#00000000" android:layout_height="1" android:layout_width="fill_parent" android:layout_weight="0dp" android:layout_below="@+id/tv_scanning_for" android:layout_centerHorizontal="true" /> </LinearLayout> 然后每个都将获得可用空间的50%。 重量工作取决于父母布局中的儿童数量。 要在Android中实现此目标,您可以使用Android:Layout_width =“ 0DP”使用ConstraintLayout或Framelayout,并相应地设置约束或边距。 <LinearLayout android:id="@+id/LinearLayoutTop" android:orientation="vertical" android:layout_width="fill_parent" android:layout_height="fill_parent" android:layout_weight="2"> </LinearLayout> <LinearLayout android:id="@+id/LinearLayoutBottom" android:orientation="vertical" android:layout_width="fill_parent" android:layout_height="fill_parent" android:layout_weight="1"> </LinearLayout> app:layout_constraintwidth_percent =“ 0.5”→将宽度设置为屏幕的50%。 应用:Layout_constraintheight_percent =“ 0.3”→将高度设置为屏幕的30%。 应用程序:Layout_constrainttop_totopof =“ parent”和app:layout_constraintbottom_tobottomof =“ parent”→垂直中心。 应用程序:layout_constraintstart_tostartof =“ parent”和app:layout_constraintend_toendof =“ parent”→水平中心。 您可以在父母布局上使用weightSum={amount of weight to distribute}在子布局上使用layout_weight=1。 <androidx.constraintlayout.widget.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android" xmlns:app="http://schemas.android.com/apk/res-auto" android:layout_width="match_parent" android:layout_height="match_parent"> <LinearLayout android:layout_width="0dp" android:layout_height="0dp" android:background="@android:color/holo_blue_light" app:layout_constraintWidth_percent="0.5" app:layout_constraintHeight_percent="0.3" app:layout_constraintTop_toTopOf="parent" app:layout_constraintBottom_toBottomOf="parent" app:layout_constraintStart_toStartOf="parent" app:layout_constraintEnd_toEndOf="parent" android:orientation="vertical"/> </androidx.constraintlayout.widget.ConstraintLayout>

回答 9 投票 0


为什么构建的图书馆的大小要大得多?

我的问题比技术更哲学。我不寻求对我特定软件问题的确切答案,而是关于为什么图书馆尺寸在不同的构建方案中可能有所不同的一般解释。

回答 1 投票 0

使用wkhtmltopdf?

I正在使用OS X中的WKHTML将HTML文件转换为PDF。我能够使用代码成功地做到这一点 /usr/local/bin/wkhtmltopdf sample.com -zoom 0.65/users/dwm8/desktop/sample.pdf 我的公关...

回答 3 投票 0

Exchange O365 中针对不同用户的不同附件大小

我遇到以下问题:外部邮件发送给我们租户的两个用户。该邮件包含一个 28 MB 的附件(发送时)。其中一位用户(用户 A)收到带有附件的邮件...

回答 1 投票 0

图像 CSS 大小调整(以适合屏幕)在 Firefox 和 Chromium 中的工作方式不同测试

以下文件在 Firefox 中按预期工作:图像适合可用的屏幕空间,没有滚动条 测试 以下文件在 Firefox 中按预期工作:图像适合可用的屏幕空间,没有滚动条 <!DOCTYPE html> <html> <head> <title>Test</title> <style> * { box-sizing: border-box; margin: 0; } body { height: 100vh; display: grid; grid-template-rows: auto 1fr auto; background-color: white; color: black; } .head { text-align: center; } .body { height: 100%; overflow: auto; display: grid; grid-template-columns: auto 1fr auto; } .left, .right { display: flex; align-items: center; justify-content: center; font-weight: bold; font-size: 300%; background-color: rgba(0,0,0,0.2); height: 1em; width: 1em; margin: auto 0.1em; border-radius: 0.5em; } .center { text-align: center; min-width: 0; min-height: 0; overflow: auto; } .center img { vertical-align: text-bottom; max-width: 100%; max-height: 100%; padding: 0.2em; } </style> </head> <body> <div class="head"> HEAD<br/>BLOCK </div> <div class="body"> <div class="left">L</div> <div class="center"> <img src="https://placehold.co/1200x900" /> </div> <div class="right">R</div> </div> </body> </html> 然而,在 Chromium 中,当窗口不够高时,会显示垂直滚动条,并且图像向上或向下移动 1px。 造成这种情况的原因是什么?如何解决(除了使用例如 calc(100% - 1px) 代替 100%)? 您需要在 overflow 类选择器中将 hidden 值更改为 .center。 .center { text-align: center; min-width: 0; min-height: 0; /*This is wrong overflow: auto; change to*/ overflow-y: hidden; }

回答 1 投票 0

如何减小 APK 大小? lib文件夹太大了

我目前正在使用 GeckoView 开发一个小项目。尽管从一个空项目开始,仅将 GeckoView 添加到依赖项(不添加任何资源或图像),AP...

回答 1 投票 0

CSS 问题:文本区域的宽度与文本输入字段的宽度不同

我正在建立一个简单的表单,其中包含两个文本输入字段和一个文本区域,我希望所有内容都完美对齐,所有三个项目都在彼此下方。我当然希望他们是

回答 1 投票 0

Linux 上的 pyinstaller 和 upx - exe 大小没有区别

我正在 Xubuntu 20.04 上使用此脚本构建一个项目。 pyinstaller --distpath $OUTPUT_DIR \ --名称 $APP_NAME \ --一个文件\ --隐藏导入 numpy \ --隐藏导入...

回答 1 投票 0

Unix命令行:如何获取最近30天内修改的文件的总大小

我想知道如何获取最近30天内修改的文件的总大小。 我发现这个命令只给我过去 30 天内修改过的文件列表。 寻找 。 -名称“*”-

回答 3 投票 0

BufferedInputStream 的缓冲区大小

使用Buffered Input Stream读取批量文件时如何确定Buffer的大小?它基于文件大小吗?我正在使用, 字节[] buf = 新字节[4096]; 如果我增加缓冲区大小...

回答 4 投票 0

如何更改 JLabel 的字体大小以获取最大尺寸

我在容器中有一个 JLabel。 字体的默认大小非常小。 我希望 JLabel 的文本采用最大尺寸。 我怎样才能做到这一点?

回答 8 投票 0

ValueError:目标大小 (torch.Size([16])) 必须与输入大小 (torch.Size([16, 1])) 相同

ValueError Traceback(最近一次调用最后一次) 在 23 输出 = 模型(数据) 24 # 计算...

回答 4 投票 0

在javascript中获取DIV宽度和高度

我试图在用户更改时获取 div 宽度和高度,并将该数字提交到另一个页面。 我似乎不知道如何获得宽度和高度。 $(功能...</desc> <question vote="11"> <p>我试图在用户更改时获取 div 宽度和高度,并将该数字提交到另一个页面。 我似乎不知道如何获得宽度和高度。</p> <pre><code>&lt;script&gt; $(function() { $( &#34;#set div&#34; ).draggable({ stack: &#34;#set div&#34;, preventCollision: true, containment: $(&#39;#main_content&#39;), stop: function(event, ui) { var mydiv = document.getElementById(&#34;set&#34;); var pos_x = ui.offset.left; var pos_y = ui.offset.top; var width = mydiv.style.width; ----THIS DOESN&#39;T WORK var height = mydiv.style.height; ----THIS DOESN&#39;T WORK var window_width = window.innerWidth; var window_height = window.innerHeight; var need = ui.helper.data(&#34;need&#34;); console.log(pos_x); console.log(pos_y); console.log(width); console.log(window_width); console.log(need); //Do the ajax call to the server $.ajax({ type: &#34;POST&#34;, url: &#34;updatecoords.php&#34;, data: { x: pos_x, y: pos_y, need_id: need, width: width, height: height, window_width: window_width, window_height: window_height} }).done(function( msg ) { alert( &#34;Data Saved: &#34; + msg ); }); } }); }); &lt;/script&gt; </code></pre> <p>正确的做法是什么?</p> </question> <answer tick="false" vote="24"> <p><strong>使用<pre><code>ele.style.width</code></pre>来获取元素的宽度是非常错误的!!!!!!</strong></p> <p>在原生 JavaScript 中,可以通过两种方式获取元素的 CSS: ##标准方法</p> <pre><code>window.getComputedStyle(ele) </code></pre> <p>例如,</p> <pre><code>var ele = document.getElementById(&#34;content&#34;), // Do not use # eleStyle = window.getComputedStyle(ele); /* Below is the width of ele */ var eleWidth = eleStyle.width; </code></pre> <p>##IE(IE 8 及之前)</p> <pre><code>element.currentStyle </code></pre> <p>例如,</p> <pre><code>var ele = document.getElementById(&#34;content&#34;), // Do not use # eleStyle = ele.currentStyle; /* Below is the width of ele */ var eleWidth = eleStyle.width; </code></pre> <p>##为什么不使用<pre><code>ele.style</code></pre>? <pre><code>ele.style</code></pre> 就是获取<pre><code>ele</code></pre>的属性样式。 如果使用 <pre><code>ele.style.width</code></pre>,您只是得到 <pre><code>ele.style</code></pre> 的宽度,而不是 <pre><code>ele</code></pre> 的真实宽度。</p> <p>如果您做过类似的事情:</p> <pre><code>ele.style.width = &#34;55px&#34; </code></pre> <p>使用 <pre><code>ele.style.width</code></pre> 时,您会得到“55px”。 如果没有,您将变得未定义。</p> <p>##如何使用 jQuery? 使用 <pre><code>$ele.width()</code></pre>(如果您想要“精确”宽度,请使用 <pre><code>$ele.outerWidth()</code></pre>),jQuery 已经为您完成了一切。</p> </answer> <answer tick="false" vote="15"> <p>在普通 JavaScript 中使用</p> <pre><code>var width = mydiv.offsetWidth; var height = mydiv.offsetHeight; </code></pre> <p>这将为您提供数值,或者</p> <pre><code>var width = mydiv.offsetWidth + &#39;px&#39;; var height = mydiv.offsetHeight + &#39;px&#39;; </code></pre> <p>如果您想要“CSS”格式。</p> </answer> <answer tick="true" vote="7"> <p>既然你已经在使用 jQuery,你可以这样做:</p> <pre><code>var width; if (need == 1) { width = $(&#34;#web&#34;).width(); } else { width = $(&#34;#set&#34;).width(); } </code></pre> </answer> <answer tick="false" vote="1"> <p>由于您正在使用 jQuery,您可能想了解以下内容:</p> <p>$('#id').outerWidth() $('#id').outerWidth(true)</p> <p>这些会非常方便。这允许您找到 div 的总宽度(内边距、边框、宽度和(可选参数)边距)。</p> <p><a href="http://api.jquery.com/outerWidth/" rel="nofollow">http://api.jquery.com/outerWidth/</a></p> </answer> </body></html>

回答 0 投票 0

如何获取 PyQt 中 QListWidget 中 QListWidgetItem 的高度?

实际上,如何在 PyQt 中提取 gui 元素的大小? 到目前为止,我只发现 sizeHint 提到了 PyQt 中有关大小的任何内容。 谁能解释一下尺寸如何在...

回答 2 投票 0

系统托盘中的图标大小是多少? [重复]

我想更改应用程序的通知图标,但不知道大小是多少才能使其正确显示。目前它会自动调整大小并破坏我的像素! 请帮忙!

回答 7 投票 0

2024 年安装时资产包的 Play Asset Delivery 大小限制

我有一个使用 AAB 的应用程序,想要确认安装时资源包的大小限制。 来自 https://support.google.com/googleplay/android-developer/answer/9859372#size_limits 它说“基本模块...

回答 1 投票 0

Python:海龟大小(以像素为单位)

如何获取Python海龟的像素尺寸?

回答 4 投票 0

如何获取Snowflake中模式和数据库的总字节大小

我喜欢 SHOW TABLES 查询如何返回列出的每个表的行和字节,但不幸的是,SHOW SCHEMAS 查询并非如此。 获取总字节数的最佳方法是什么...

回答 2 投票 0

C++/二维向量的大小

如何找到二维向量的大小?到目前为止,我有以下无法编译的代码。 #包括 #包括 使用命名空间 std; int main() {

回答 5 投票 0

最新问题
© www.soinside.com 2019 - 2024. All rights reserved.