我了解Android的开发者网站提供了有关此主题的信息.我已经阅读了以下三页:
他们没有提供我正在寻找的信息/统计数据.从第二个链接来看,支持的两个最重要的屏幕类别是normal-hdpi和normal-mdpi.
问题是,仅仅知道这两个类别最受欢迎对我没有帮助.该网站为我提供了这些类别的屏幕尺寸和密度范围,但范围非常大.
我想知道这两个类别中最流行的手机是什么.更具体地说,我正在寻找这两个类别中最受欢迎的决议.
我知道,已经讨论了1000次,但我不能调整不同屏幕尺寸的文字大小.我尝试在自定义样式中使用'sp'作为大小单位:
<style name="CustumButtonStyle" parent="@android:style/Widget.Button">
...
<item name="android:textSize">30sp</item>
...
</style>
Run Code Online (Sandbox Code Playgroud)
在2.7 QVGA中它看起来不错:
但在7in WSVGA中它看起来像这样:

我试图使用'sp'和'dp'同样的结果.
您能解释一下如何在任何屏幕上使这些按钮看起来一样吗?
完整的自定义按钮样式
<style name="CustumButtonStyle" parent="@android:style/Widget.Button">
<item name="android:background">@drawable/custom_button</item>
<item name="android:layout_width">fill_parent</item>
<item name="android:layout_height">wrap_content</item>
<item name="android:layout_margin">3dp</item>
<item name="android:textColor">#ffffff</item>
<item name="android:gravity">center</item>
<item name="android:textSize">30sp</item>
<item name="android:textStyle">bold</item>
<item name="android:shadowColor">#000000</item>
<item name="android:shadowDx">1</item>
<item name="android:shadowDy">1</item>
<item name="android:shadowRadius">2</item>
</style>
Run Code Online (Sandbox Code Playgroud)
在我的应用主题中,我有
<item name="android:buttonStyle">@style/CustumButtonStyle</item>
Run Code Online (Sandbox Code Playgroud)
还有我的布局:
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/RelativeLayout1"
android:layout_width="fill_parent"
android:background="@drawable/grid"
android:gravity="center"
android:orientation="vertical" android:layout_height="fill_parent">
<Button
android:id="@+id/buttonContinue"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentTop="true"
android:layout_centerHorizontal="true"
android:layout_gravity="center"
android:gravity="center"
android:text="@string/continue_game" android:layout_marginTop="3dp" android:layout_marginBottom="3dp"/>
<Button
android:id="@+id/buttonNewGame"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignLeft="@+id/buttonContinue"
android:layout_alignRight="@+id/buttonContinue"
android:layout_below="@+id/buttonContinue"
android:layout_gravity="center"
android:gravity="center"
android:text="@string/new_game" android:layout_marginTop="3dp" android:layout_marginBottom="3dp"/>
<Button …Run Code Online (Sandbox Code Playgroud) 这可能吗?我想要的是英寸数,而不是像素数.我知道它大概是160 ppi.但不完全是.
我怎么知道我的活动的可见大小?
我试图获得活动的实际尺寸,
而不是从getHeight()和的高度和宽度getWidth(),
这给了我屏幕的全尺寸.
我在flutter上创建了一个新的应用程序,在不同设备之间切换时我遇到了屏幕尺寸问题.
我使用Pixel 2XL屏幕尺寸创建了应用程序,因为我有容器和ListView的子容器,所以要求我包含容器的高度和宽度.
因此,当我将设备切换到新设备时,容器太长并且抛出错误.
我该如何制作它以便应用程序针对所有屏幕进行优化?
我有几个问题:
什么是屏幕尺寸?
什么是屏幕密度?
是什么区别之间的屏幕尺寸和屏幕密度?
如何在Android中支持不同的密度和不同的屏幕尺寸?
我已经阅读了官方文档,但我无法理解屏幕大小和屏幕密度之间的差异.
想象一下完整的Android设备屏幕,我希望它分为两部分:
具体看一些场景:
目前我已经为这两个部分分配了权重,这也不算太糟糕,但是如果文本很小,地图就不会扩展以占用空间,并且布局有一个浪费的空白,地图可以有用的.
我已经尝试了大量的组合但却看不出如何实现这一点.对我来说似乎是一种常见的经历,我知道自己想要什么,但却无法看到如何获得可用的视图来实现它.我希望有一个很简单的方法来做到这一点.
请随意让我看起来像个傻瓜,并指出我错过的明显属性:-)
================================================== ====================
据我所知,只有在声明性XML中才能做到这一点,它需要在代码中完成.我将文本部分高度设置为wrap_content,权重设置为0(不调整大小),并将地图设置为weight = 1(即占用剩余空间).然后我检查文本部分(在ScrollView中)是否占用了太多空间,如果是,则将其缩小.此代码需要更改以支持不同的布局方向.
private void fixLayoutProportions()
{
float maxPercentageOfScreenForText = 50/100;
LinearLayout container = (LinearLayout)findViewById(R.id.container);
ScrollView eventText = (ScrollView)findViewById(R.id.text_scroller);
int heightAvailable = container.getHeight();
int scrollerHeight = eventText.getHeight();
if ( scrollerHeight>(heightAvailable*maxPercentageOfScreenForText) ) // Text section using too much space
{
eventText.getLayoutParams().height = (int)(heightAvailable*maxPercentageOfScreenForText) ;
eventText.invalidate();
}
}
Run Code Online (Sandbox Code Playgroud) 如何在WP7上以编程方式获得屏幕分辨率?以下是一组在桌面WPF和Silverlight中完成相同工作的链接,但它们都不在Phone SDK中.
有任何想法吗?
http://social.msdn.microsoft.com/Forums/en-US/windowsphone7series/thread/f0639904-a368-44db-9ddd-efcaf8fc736e
http://social.msdn.microsoft.com/Forums/en-US/wpf/thread/6b6b832f-0dfd-428c-84cd-b1b9e7f236cf
如何获取活动屏幕尺寸?
http://social.msdn.microsoft.com/Forums/en-US/windowsphone7series/thread/f0639904-a368-44db-9ddd-efcaf8fc736e
我正在尝试创建一个php库,这就是为什么我需要一个好的Mask,以后可以显示图片.我希望Mask不要大于屏幕大小.我的意思是,必须没有滚动,整体<body>需要只有浏览器窗口的宽度和高度,这样每个子对象<body>都限制在浏览器的帧大小,如果溢出则会缩小.我试着max-width和max-height上<body>,但它不工作.
这是我的代码:
index.html的:
<!DOCTYPE html>
<html>
<head>
<link rel="stylesheet" type="text/css" href="style.css">
</head>
<body>
<div id="mother">
<div id="header">
<div id="back-link">
<a href="../">Home</a>
</div>
<div id="prev">
<a href="">next picture</a>
</div>
<div id="next">
<a href="">previous picture</a>
</div>
<div id="headline">
<p class="h2">Our Galery</p>
</div>
</div>
<!-- Content -->
<div id="container-bild">
<img src="./bilder/P1130079.JPG" id="img-bild" />
</div>
</div>
</body>
</html>
Run Code Online (Sandbox Code Playgroud)
style.css中:
body {
max-width: 100%;
max-height: 100%;
}
/* mother-container */
div#mother {
max-width: 100%;
max-height: …Run Code Online (Sandbox Code Playgroud)