【发布时间】:2018-07-30 12:27:21
【问题描述】:
我想更新搜索栏 UI,使搜索栏的两个端点都有一条垂直线。我通过在 android:progressDrawable 属性中设置自定义可绘制图像(在端点处带有垂直线的水平线)来尝试此操作,但该搜索栏不可见(只有拇指可见)。我还尝试在搜索栏的左侧和右侧创建自定义视图,但垂直线不会保持在不同设备中的确切位置。此外,由于搜索栏具有默认的左右填充,我需要提供边距以在搜索栏端点处准确显示垂直线,这对于不同的设备可能会有所不同。
实现此要求的理想方法是什么?
<SeekBar
android:id="@+id/seekBar"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:maxHeight="@dimen/dp1"
android:paddingLeft="0px"
android:paddingRight="0px"
android:progressDrawable="@color/white"/>
<View
android:layout_width="@dimen/dp1"
android:layout_height="@dimen/dp10"
android:layout_alignLeft="@+id/seekBar"
android:layout_alignTop="@+id/seekBar"
android:layout_marginLeft="@dimen/dp16"
android:bawrckground="@color/white"
android:id="@+id/view" />
<View
android:layout_width="@dimen/dp1"
android:layout_height="@dimen/dp10"
android:layout_alignRight="@+id/seekBar"
android:layout_alignTop="@+id/seekBar"
android:layout_marginRight="@dimen/dp16"
android:background="@color/white”/>
【问题讨论】:
-
好的。你能展示任何原型吗??
-
@IntelliJAmiya 目前我无法共享图像。但是 Seekbar 应该看起来像一条带有垂直端点的水平线。垂直线应该与水平线成直角。
-
这是一个 xml 问题。
-
@IntelliJAmiya 垂直线应该正好在 seekbar 轨道端点的位置。问题是 seekbar 有一些默认填充,因此这些线在轨道端点处不完全可见。
-
@IntelliJAmiya 另外垂直线应该与水平线成直角。它不应该低于水平线。
标签: android android-layout seekbar android-seekbar