android - 我不知道如何使用边距在布局中移动仪表
问题描述
我在应用程序中有仪表,我想将它移动到页面的中心。但是如果我做任何事情,就不会发生任何变化
<?xml version="1.0" encoding="utf-8"?>
<android.support.constraint.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:id="@+id/layout_noise"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="@drawable/bg_sc">
<com.github.anastr.speedviewlib.TubeSpeedometer
android:id="@+id/gauge"
android:layout_width="wrap_content"
android:layout_height="0dp"
android:layout_marginLeft="600dp"
/>
<TextView
android:id="@+id/tv_noise"
android:layout_width="wrap_content"
android:layout_height="0dp"
android:layout_marginTop="500dp"
android:fontFamily="serif"
android:text="Odmeraj amotsferu"
android:textSize="36sp"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent" />
</android.support.constraint.ConstraintLayout>
您可以在应用程序中看到它:
谢谢!
解决方案
您应该使用@Harin Kaklotar
.
改变
<com.github.anastr.speedviewlib.TubeSpeedometer
android:id="@+id/gauge"
android:layout_width="wrap_content"
android:layout_height="0dp"
android:layout_marginLeft="600dp"
/>
至
<com.github.anastr.speedviewlib.TubeSpeedometer
android:id="@+id/gauge"
android:layout_width="wrap_content"
android:layout_height="0dp"
android:layout_marginLeft="600dp"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent"
/>
您已经在tv_noise
. 所以我建议你先阅读ConstraintLayout和How to Build a Responsive UI with ConstraintLayout。
推荐阅读
- java - 我找不到我首先从 JTextField 输入的值的原因
- javascript - 从 Summernote 中删除 Arial 和 Helvetica 字体
- reactjs - 如何从 react-router Switch 语句将道具传递给组件
- java - Eclipse e4 RCP 中注释方法的可见性
- sql-server - ssis包终止后继续在datafactory中执行
- javascript - 关闭指定模式的一个功能?
- multithreading - ThreadSanitizer:信号处理程序破坏 errno - 如何避免设置 errno
- .htaccess - 将 https 强制添加到 .htaccess 中的第二个域
- r - 在r中制作两个百分比变量的分组条形图
- excel - CreateProcess 没有为 OSK 检索正确的 PID