android - 如何将 EditText 放置在 Android 屏幕上的特定像素中?

标签 android xml

我想将我的 EditText 放置在 Android 应用程序屏幕上的特定位置,但我看不到任何方法将其放置在正确的像素中或使用 x 和 y 坐标将其放置在它所在的位置必须出现。

我的EditText是这样的:

<EditText android:id="@+id/txtExample"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:textSize="20sp"
        android:width="250dp"
        android:layout_marginTop="30dp"
        android:layout_below="@+id/lblExample"
        android:layout_centerHorizontal="true" />

如您所见,此 EditText 下面有一个标签,但我将此 EditText 与上面的标签一起计算边距,因此我尝试搜索 Android 的某些功能,如 android,但没有任何结果:...,如果可能的话,将其放置在左上角以作为您要放置元素的位置的引用。

如有任何帮助,我们将不胜感激。

提前致谢!

最佳答案

使用特定像素已经过时了,因为我们使用“dp”的概念,因为每个设备的像素不会发生变化。如果您想放置在某个特定位置,请使用“重力”和“边距”来定位它。这是最简单、最好的快速完成方法。

关于android - 如何将 EditText 放置在 Android 屏幕上的特定像素中?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/30494552/

相关文章:

android - Cordova 构建 |运行失败 - compileDebugJavaWithJavac

xml - 解码包含数据和子节点的 xml 节点

xml - Android Studio 在预览打开的情况下编辑布局时卡住?

javascript - jQuery : Take the exact value from the xml

c# - 如何获取 XElement,如果不存在则创建它?

android - (Android) Bundle 和 Application 哪个更好?

java - 创建自定义外观的 android Activity

Android AudioTrack 和 AudioRecord 奇怪的行为

Android + XAMARIN + 强制屏幕停留在 "Portrait"模式(使用 AndroidManifest)

c# - 了解 WCF 响应中的 xmlns 标记