首页 \ 问答 \ Android:以英寸为单位设置View的宽度(在英寸和dp之间转换)(Android: Setting width of View in inches (converting between inches and dp))

Android:以英寸为单位设置View的宽度(在英寸和dp之间转换)(Android: Setting width of View in inches (converting between inches and dp))

我正在制作一个标尺应用程序,我希望我的一个视图在任何屏幕上都是1.7英寸宽,无论使用该应用程序的个别设备的dpi如何。 我知道如何在像素和dp之间进行转换以及如何以编程方式设置视图的布局参数,但我不确定如何确定每个屏幕密度需要多少dp以确保我的视图始终以宽度绘制1.7英寸。

除非我弄错了,一旦我理解了这个转换,我应该可以使用这样的调用来设置它:

RelativeLayout.LayoutParams viewParams = new RelativeLayout.LayoutParams( **width in dp converted from inches**, RelativeLayout.LayoutParams.MATCH_PARENT);

I'm making a ruler app and I want one of my views to be exactly 1.7 inches in width on any screen, regardless of the dpi of the individual device using the app. I know how to convert between pixels and dp and how to programmatically set the layout parameters of a view, but i'm not sure how to determine how many dp will be needed at each screen density to ensure my view is always drawn with a width of 1.7 inches.

Unless i'm mistaken, once I understand this conversion, I should be able to set this using a call like this:

RelativeLayout.LayoutParams viewParams = new RelativeLayout.LayoutParams( **width in dp converted from inches**, RelativeLayout.LayoutParams.MATCH_PARENT);

原文:https://stackoverflow.com/questions/40194171
更新时间:2022-02-15 08:02

最满意答案

如果没有帮助,您无法为Google Analytics设置BigQuery。 首先,您需要与高级支持经理https://support.google.com/analytics/answer/3437618联系,并向他提供两项信息:

  • 应该接收数据的BigQuery项目ID
  • Google Analytics视图ID

您的Google Analytics帐户可以处理多个媒体资源,每个媒体资源都可以拥有多个视图。 视图是为单个属性收集的数据的子集(由自定义过滤器定义)。 默认情况下,每个属性都有一个包含该属性的所有数据的视图。 目前,Google Analytics仅支持将每个属性的单个视图导出到BigQuery,因此您很可能希望将此未过滤的视图推送到BigQuery,因为这样您就可以对属性的所有数据运行查询。 提交此请求时,系统会指示您修改项目的ACL,以便Google Analytics可以将数据写入项目。 具体而言,系统会要求您为该帐户的项目添加编辑权限: analytics-processing-dev@system.gserviceaccount.com

完成此操作后,支持会更新您的帐户配置,以便夜间作业将您的数据推送到项目中。 将创建一个数据集,其名称等于您在请求中指定的视图ID,并且在该数据集中,将在一天结束后的某个时间创建每日表。 表格具有以下命名模式: ga_sessions_YYYYMMDD

幸运的是您可以尝试使用此功能,而无需完成所有此设置,甚至无法注册高级帐户 。 Google Analytics小组提供了一个示例数据集,您可以使用该数据集来了解生成的数据的性质。 您可以使用项目菜单(项目名称旁边的下拉菜单,切换到项目➪显示项目)添加项目google.com:analytics-bigquery将此数据添加到BigQuery UI中的视图中。 或者,您可以导航到BigQuery UI链接https://bigquery.cloud.google.com/project/google.com:analytics-bigquery添加项目后,示例数据集(LondonCycleHelmet)将显示在导航面板中。 它包含两个表:

  • ga_sessions_20130910
  • refunds_201309

现在你可以忽略第二个表。 第一个表是示例表,其中包含与用户与网络媒体资源互动时Google Analytics收集的数据相对应的数据。 选择表将显示具有大量字段的复杂模式


You cannot set up BigQuery for Analytics without assistance. To start you need to contact your Premium support manager https://support.google.com/analytics/answer/3437618 and give him two bits of information:

  • BigQuery project ID that should receive your data
  • Google Analytics view ID

Your Google Analytics account can handle multiple properties and each property can have more than one view. A view is a subset of the data (defined by custom filters) collected for a single property. By default, every property has a single view that contains all the data for the property. Currently Google Analytics supports only exporting a single view per property to BigQuery, so most likely you want to have this unfiltered view pushed into BigQuery because then you can run queries over all the data for your property. When you submit this request, you will be instructed to modify the ACL of your project so that Google Analytics can write data to your project. Specifically, you will be asked to add edit permissions on the project for the account: analytics-processing-dev@system.gserviceaccount.com

After you have done this, support updates your account configuration so that a nightly job pushes your data into the project. A dataset will be created with a name equal to the view ID you specified in the request, and within that dataset a daily table will be created some time after the end of the day. The tables have the following naming pattern:ga_sessions_YYYYMMDD

Fortunately, you can experiment with this feature without going through all this setup or even signing up for a Premium account. The Google Analytics team provides a sample dataset that you can use to understand the nature of the data generated. You can add this data to your view in the BigQuery UI by adding the project google.com:analytics-bigquery using the project menu (the drop-down next to the project name, Switch to Project ➪ Display Project). Alternately, you can navigate to the BigQuery UI link https://bigquery.cloud.google.com/project/google.com:analytics-bigquery After you add the project, the sample dataset (LondonCycleHelmet) appears in the navigation panel. It contains two tables:

  • ga_sessions_20130910
  • refunds_201309

For now you can ignore the second table. The first table is the sample table that contains data that corresponds to what Google Analytics collects when users interact with a web property. Selecting the table displays a complicated schema that has a large number of fields

相关问答

更多
  • 为了能够从同一页面中分辨出不同的链接,例如,您需要通过此命令要求插件来设置增强的链接属性 ga('require', 'linkid', 'linkid.js'); 该插件还需要装饰每个链接,这些链接引用同一目的地(问题)一个唯一的ID。 你也可以选择装饰一个容器元素,比如一个包含链接或其父级的div(最多5个级别) 有很多方法可以获得这些数据。 一种方法是报告行为>行为流程。 该视图包含了太阳图。 您可以使用自定义细分来缩小范围+创建内容分组。 行为流的优点是它是可视的 - 但很难定制。 您可以采取的另 ...
  • 您不需要做一些特别的事情 - 只需在您的网站页面上放置正确的GATC并标记您通过UTM URL构建器放置在网站之外的链接。 GA为您解析所有。 You don`t need to do something special - just put correct GATC on your site pages and mark links, which you placed outside your site by UTM URL builder. GA parses all for You.
  • 这可能是不可能的。 Facebook应该提供自己的分析。 原因,你不能拥有它是因为facebook出于安全原因可能会从你发布的内容中删除Javascript。 从这里开始: https : //www.facebook.com/help/336893449723054/ That is probably impossible. Facebook should provide their own analytics. Reason, you can't have it is because facebook ...
  • 您正尝试根据维度对结果进行排序,该维度未包含在结果集中。 您有ga:daysToTransaction和ga:sessionsToTransactions维度,并且您已尝试根据ga:date应用排序。 您需要使用它进行排序: sort = c("ga:daysToTransaction") 我不清楚,如果你在脚本的另一部分使用ga:sessionsToTransactions,因为它会添加与你想要的输出相比的其他细分,需要稍后聚合以获得预期的结果。 此外,您是否计算脚本其他部分的%total,或者您希望将 ...
  • 加倍其他指标? 如果有200%的差异,你有没有加倍的chartbeat? 什么是允许的cookie? 这是用户选择退出参数吗? 那么它只跟踪同意被跟踪的用户? Doubled other metrics? If there is 200% difference, dont you have doubled chartbeat? What is cookie to allow? Is that something like user opt-out parameter? So it tracks only u ...
  • 如果没有帮助,您无法为Google Analytics设置BigQuery。 首先,您需要与高级支持经理https://support.google.com/analytics/answer/3437618联系,并向他提供两项信息: 应该接收数据的BigQuery项目ID Google Analytics视图ID 您的Google Analytics帐户可以处理多个媒体资源,每个媒体资源都可以拥有多个视图。 视图是为单个属性收集的数据的子集(由自定义过滤器定义)。 默认情况下,每个属性都有一个包含该属性的所 ...
  • 您可以使用Core Reporting API时间 - 维度和指标来分割数据。 例如,如果您想将其更改为小时,则可以执行以下操作: .setDimensions("ga:dateHour") 如果您想预览api可以获取的数据,请使用GA Query Explorer 。 There are quite a few ways you can slice up your data using the Core Reporting API Time - Dimensions & Metrics. For ins ...
  • 有类似的问题。 您可以使用以下内容附加到URL: window.location.hash = '#/' + pageNumber; 然后在GA中使用它: _gaq.push(['_trackPageview', location.pathname + location.search + location.hash]); Had a similar problem. You could append to the URL using something like: window.location.has ...
  • 您可以调用帐户Summaries API并查找用户有权访问的帐户的完整列表。 summary = gapi.client.analytics.management.accountSummaries.list(); 然后循环结果以验证属性或视图是否在列表中。 但是你也可以包含一个视图选择器组件,这样你就只能使用用户有权访问的视图ID。 You could call the accounts Summaries API and find the complete list of accounts to whi ...
  • 好吧,似乎我终于解决了我的问题。 我回答自己是为了帮助有类似问题的人,并希望他们也能为他们工作。 答案很简单,有关Google Analytics的文档有点令人困惑,但如果有人想要添加维度,则指标(或编辑Google分析中的示例查询)只需在以下链接中添加代码: https://developers.google.com/analytics/devguides/reporting/core/v3/coreDevguide 只需在查询示例之后添加此代码(如果您想添加维度): setDimensions("ga: ...

相关文章

更多

最新问答

更多
  • 您如何使用git diff文件,并将其应用于同一存储库的副本的本地分支?(How do you take a git diff file, and apply it to a local branch that is a copy of the same repository?)
  • 将长浮点值剪切为2个小数点并复制到字符数组(Cut Long Float Value to 2 decimal points and copy to Character Array)
  • OctoberCMS侧边栏不呈现(OctoberCMS Sidebar not rendering)
  • 页面加载后对象是否有资格进行垃圾回收?(Are objects eligible for garbage collection after the page loads?)
  • codeigniter中的语言不能按预期工作(language in codeigniter doesn' t work as expected)
  • 在计算机拍照在哪里进入
  • 使用cin.get()从c ++中的输入流中丢弃不需要的字符(Using cin.get() to discard unwanted characters from the input stream in c++)
  • No for循环将在for循环中运行。(No for loop will run inside for loop. Testing for primes)
  • 单页应用程序:页面重新加载(Single Page Application: page reload)
  • 在循环中选择具有相似模式的列名称(Selecting Column Name With Similar Pattern in a Loop)
  • System.StackOverflow错误(System.StackOverflow error)
  • KnockoutJS未在嵌套模板上应用beforeRemove和afterAdd(KnockoutJS not applying beforeRemove and afterAdd on nested templates)
  • 散列包括方法和/或嵌套属性(Hash include methods and/or nested attributes)
  • android - 如何避免使用Samsung RFS文件系统延迟/冻结?(android - how to avoid lag/freezes with Samsung RFS filesystem?)
  • TensorFlow:基于索引列表创建新张量(TensorFlow: Create a new tensor based on list of indices)
  • 企业安全培训的各项内容
  • 错误:RPC失败;(error: RPC failed; curl transfer closed with outstanding read data remaining)
  • C#类名中允许哪些字符?(What characters are allowed in C# class name?)
  • NumPy:将int64值存储在np.array中并使用dtype float64并将其转换回整数是否安全?(NumPy: Is it safe to store an int64 value in an np.array with dtype float64 and later convert it back to integer?)
  • 注销后如何隐藏导航portlet?(How to hide navigation portlet after logout?)
  • 将多个行和可变行移动到列(moving multiple and variable rows to columns)
  • 提交表单时忽略基础href,而不使用Javascript(ignore base href when submitting form, without using Javascript)
  • 对setOnInfoWindowClickListener的意图(Intent on setOnInfoWindowClickListener)
  • Angular $资源不会改变方法(Angular $resource doesn't change method)
  • 在Angular 5中不是一个函数(is not a function in Angular 5)
  • 如何配置Composite C1以将.m和桌面作为同一站点提供服务(How to configure Composite C1 to serve .m and desktop as the same site)
  • 不适用:悬停在悬停时:在元素之前[复制](Don't apply :hover when hovering on :before element [duplicate])
  • 常见的python rpc和cli接口(Common python rpc and cli interface)
  • Mysql DB单个字段匹配多个其他字段(Mysql DB single field matching to multiple other fields)
  • 产品页面上的Magento Up出售对齐问题(Magento Up sell alignment issue on the products page)