为什么我在Android的xml布局中有这个Alert消息
消息是避免使用"px"作为联合,而是使用"dp"
我有一个虚线分隔符
<?xml version="1.0" encoding="utf-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android"
android:shape="line">
<!--
#17b851 #C7B299
-->
<stroke
android:color="#9e9c85"
android:dashWidth="10px"
android:dashGap="10px"
/>
</shape>
Run Code Online (Sandbox Code Playgroud)
现在它几乎看不到.我怎样才能让它变厚.我尝试给android:height ="2px"和android:dashHeight ="5px",但它没有用.
40px的sp值是多少?还请告诉转换公式.
我试图将psd中存在的字体大小转换为mdpi密度的sp单位,即160 dpi的320*480
我有这些单选按钮,他们需要android:width="X",android:height"X"但是,我不知道如何设置这些属性,以便他们适应不同的屏幕尺寸.
这是我用于按钮的代码:
<RadioGroup android:layout_width="fill_parent"
android:layout_height="50px" android:orientation="horizontal"
android:checkedButton="@+id/first" android:id="@+id/states">
<RadioButton android:id="@+id/first"
android:background="@drawable/button_radio" android:width="50px"
android:height="50px" />
<RadioButton android:id="@+id/second"
android:background="@drawable/button_radio" android:width="50px"
android:height="50px" />
<RadioButton android:id="@+id/third"
android:background="@drawable/button_radio" android:width="50px"
android:height="50px" />
<RadioButton android:id="@+id/fourth"
android:background="@drawable/button_radio" android:width="50px"
android:height="50px" />
<RadioButton android:id="@+id/fifth"
android:background="@drawable/button_radio" android:width="50px"
android:height="50px" />
</RadioGroup>
Run Code Online (Sandbox Code Playgroud)
我已经尝试将单选按钮放在表格行中,但之后它们无法正常运行.当我点击一个时,它选择了它,但是当我点击另一个时它没有取消选择它.
我试过更换android:width用的android:layout_width但是他们没有显示.
我也尝试过使用dip,但是按钮没有显示出来.
我还应该补充一点,我使用的是drawables而不是stock单选按钮.我不知道这是否有所作为,但是drawables的大小都相同(50px x 50px).
有谁知道我如何设置这些的高度和宽度,以便他们将自己调整到不同的屏幕尺寸?
其测量应该在Android中使用:px,dp,dip或sp???
在Android布局设计中是否存在任何百分比类型的东西,就像我们在CSS中用于Web开发一样.
Android中可以安全地使用哪种测量来设计跨手机兼容性.
我的Android应用程序中的一个活动具有两个图像视图的相对布局,这两个图像视图在xml布局文件中设置.如何以编程方式获取imageviews的x,y位置
这些坐标会根据屏幕尺寸和密度而有所不同吗?
我想要做的是让用户触摸image1,然后将其动画化以移动到image2的位置.
显然,由于我将这些图像放在xml中,我知道它们的x,y坐标,但我担心这些坐标会根据屏幕尺寸和密度而变化.
当我尝试将常规按钮和ImageButton设置为相同时,我在LinearLayout中得到了一些奇怪的行为layout_weight.图像按钮的android:src资源非常小,非常适合ImageButton,没有任何问题.即使它们的宽度应该相同,但由于某种原因,ImageButton的宽度大约是普通按钮其余部分的2/3.如果我将ImageButton的乘以layout_weight10,它更接近正确的大小,但为什么这不起作用?
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal"
android:layout_weight="1">
<Button
android:id="@+id/clear"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="1"
android:text="@string/clear"/>
<Button
android:id="@+id/left_paren"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="1"
android:text="@string/left_paren"/>
<Button
android:id="@+id/right_paren"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="1"
android:text="@string/right_paren"/>
<ImageButton
android:id="@+id/backspace"
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:layout_weight="1"
android:adjustViewBounds="true"
android:contentDescription="@string/backspace"
android:src="@drawable/backspace"/>
</LinearLayout>
Run Code Online (Sandbox Code Playgroud) android android-layout android-imagebutton android-layout-weight
我想在Android上布局我的所有屏幕,以便它们与任何屏幕尺寸和分辨率兼容.所以我认为最好的方法是使用weight属性来使用某种相对规范.
我知道如何指定按钮的宽度相对于其父项,但我不知道如何将其应用于布局的所有方面.它背后的逻辑理想情况如下:
horizontalSize = 100%
verticalSize = 100%
Button1:
20% padding to top <- no idea, how to do this, (only using fixed sizes in relative layout)
10% height <- no idea, how to do this
50% width <- with weight attribute
center horizontally <- with layout_centerHorizontal
Button2:
20% padding to Button1 <- only know relative with use of fixed pixels
5% padding to left
30% width
10% height
Button3:
20% padding to Button1
5% padding to right …Run Code Online (Sandbox Code Playgroud) 我是android开发的初学者.我刚在main.xml文件中创建了一个按钮
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:orientation="vertical" >
<Button
android:text="Click"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
/>
Run Code Online (Sandbox Code Playgroud)
我只给android的整数值:但我得到错误错误:错误:不允许整数类型
如何为Button提供固定的宽度和高度?android:layout_width和android:Width之间的主要区别是什么?
谢谢.
我正在开发一个应用程序,现在我正在设计阶段.我
使用线性布局在日食中在3.7WVGA(Nexus One)屏幕上设计了一个屏幕.但是当我在2.7上测试时,
我的一些图标就会出现在屏幕之外.我的问题是哪种布局适合所有屏幕,无论我是设计在3.7英寸还是在2.7上运行.
请给我一个建议.
提前致谢.


第一部分我在3.7中设计,在2.7中设计第二.
android ×10
screen ×2
xml ×2
alert ×1
layout ×1
paint ×1
radio-button ×1
resolution ×1
size ×1
stroke ×1