【发布时间】:2017-10-18 15:18:10
【问题描述】:
所以我想在下面link(material.io)
中实现与材料指南中相同的风格到目前为止,我已经尝试过这种方式:
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:orientation="vertical" android:layout_width="match_parent"
android:layout_height="match_parent">
<ProgressBar
android:indeterminate="true"
android:id="@+id/progressbar"
android:layout_width="match_parent"
android:layout_height="wrap_content"
style="@style/Widget.AppCompat.ProgressBar.Horizontal"
/>
<LinearLayout
android:elevation="2dp"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_margin="8dp"
android:background="@color/white"
android:orientation="vertical"
android:paddingBottom="64dp"
android:paddingLeft="64dp"
android:paddingRight="64dp"
android:paddingTop="32dp">
<TextView
android:id="@+id/textView"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:gravity="center"
android:paddingBottom="32dp"
android:paddingTop="32dp"
android:text="@string/patient_register"
android:textSize="30sp" />
<ImageView
android:id="@+id/imageView"
android:layout_width="match_parent"
android:layout_height="wrap_content"
app:srcCompat="@mipmap/ic_launcher" />
<TextView
android:id="@+id/textView2"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="32dp"
android:text="@string/login_with_your_clinic"
android:textSize="18sp" />
<EditText
android:id="@+id/editText5"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="32dp"
android:ems="10"
android:hint="@string/email_address"
android:inputType="textEmailAddress" />
<EditText
android:id="@+id/editText6"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:ems="10"
android:hint="@string/password"
android:inputType="textPassword" />
<Button
android:id="@+id/login_btn"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="32dp"
android:text="@string/login"
android:textColor="@color/white"
android:theme="@style/MyButton" />
</LinearLayout>
结果如下:
为什么动作条和进度条之间有那么大的差距?我怎样才能达到谷歌材料指南中看到的结果?
【问题讨论】:
-
可以在progressBar中添加marginBottom。
-
@FatihOzcan 为什么要添加底部边距?我想消除 ProgressBar 顶部的间隙
-
那是因为那个间隙仍然是 ActionBar(它有一些高度)。如果您制作一个没有任何高度的自定义工具栏,则 ActionBar 和 Progressbar 之间不会有任何阴影。
-
我以为您正在努力弥补这一差距。您可以通过将进度条更改为不同的颜色来检查进度条的宽度和高度,以确保进度条是否均匀放置。可能就像 JMedinilla 所说的那样。当您希望查看视图的宽度和高度时,更改它的颜色是一种简单而有用的解决方案
-
好吧,我错了,但不是在问题上,而是在组件上。该空间来自进度条。您可以将鼠标放在预览布局上查看组件占用了多少空间,就像 Faith Ozcan 所说:imgur.com/a/jgK5o
标签: android material-design android-progressbar