我想设计一个看起来像下图中的搜索条.

通过使用默认搜索条,我将得到这样的东西:

所以我需要的是只改变颜色.我不需要额外的款式.是否有任何直接的方法来做这个或我应该建立我的自定义drawable.?
我尝试构建自定义的一个,但我无法得到如上所示的确切的一个.使用自定义drawable后,我得到的如下所示:

如果我需要构建自定义的那个,那么请建议如何减少进度线的宽度以及形状.
我的自定义实现:
background_fill.xml:
<?xml version="1.0" encoding="UTF-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android" >
<gradient
android:angle="90"
android:centerColor="#FF555555"
android:endColor="#FF555555"
android:startColor="#FF555555" />
<corners android:radius="1dp" />
<stroke
android:width="1dp"
android:color="#50999999" />
<stroke
android:width="1dp"
android:color="#70555555" />
</shape>
Run Code Online (Sandbox Code Playgroud)
progess_fill.xml
<?xml version="1.0" encoding="UTF-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android" >
<gradient
android:angle="90"
android:centerColor="#FFB80000"
android:endColor="#FFFF4400"
android:startColor="#FF470000" />
<corners android:radius="1dp" />
<stroke
android:width="1dp"
android:color="#50999999" />
<stroke
android:width="1dp"
android:color="#70555555" />
</shape>
Run Code Online (Sandbox Code Playgroud)
progress.xml
<?xml version="1.0" encoding="utf-8"?>
<layer-list xmlns:android="http://schemas.android.com/apk/res/android" >
<item
android:id="@android:id/background"
android:drawable="@drawable/background_fill"/>
<item android:id="@android:id/progress">
<clip android:drawable="@drawable/progress_fill" />
</item>
</layer-list>
Run Code Online (Sandbox Code Playgroud)
thumb.xml
<?xml version="1.0" encoding="UTF-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android"
android:shape="oval" …Run Code Online (Sandbox Code Playgroud) 我有一个简单的播放器和录音机.一切都很好,但有一个问题.我想添加搜索栏以查看播放记录的进度,并使用此搜索栏来设置播放器应该播放的位置.我有onProgress但没有效果.这是代码:
package com.example.recorder;
import java.io.IOException;
import android.app.Activity;
import android.media.MediaPlayer;
import android.media.MediaRecorder;
import android.os.Bundle;
import android.os.Environment;
import android.util.Log;
import android.view.View;
import android.view.View.OnClickListener;
import android.widget.Button;
import android.widget.SeekBar;
import android.widget.SeekBar.OnSeekBarChangeListener;
public class MainActivity extends Activity implements OnSeekBarChangeListener
{
private static final String LOG_TAG = "AudioRecordTest";
private static String mFileName = null;
private SeekBar seekBar;
private MediaRecorder mRecorder = null;
private Button startRecord, startPlaying, stopPlaying;
private MediaPlayer mPlayer = null;
private void onRecord(boolean start) {
if (start) {
startRecording();
} else {
stopRecording();
} …Run Code Online (Sandbox Code Playgroud) 使用带有SeekBar视图的自定义拇指绘图时,拇指绘图将被剪裁在视图的左右边缘.
我该如何解决这个问题?
这是我的搜索栏:
<SeekBar
android:id="@+id/seek1"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_margin="10dp"
android:progressDrawable="@drawable/style_progressbar"
android:thumb="@drawable/style_progressbar_circle"
android:progress="20" />
Run Code Online (Sandbox Code Playgroud)
这是style_progressbar.xml:
<layer-list xmlns:android="http://schemas.android.com/apk/res/android">
<item android:id="@android:id/background">
<shape android:shape="rectangle" >
<corners android:radius="5dp" />
<gradient
android:angle="270"
android:endColor="@color/gris_hint"
android:startColor="@color/gris_hint" />
</shape>
</item>
<item android:id="@android:id/secondaryProgress">
<clip>
<shape android:shape="rectangle" >
<corners android:radius="5dp" />
<gradient
android:angle="270"
android:endColor="@color/gris"
android:startColor="@color/gris" />
</shape>
</clip>
</item>
<item android:id="@android:id/progress">
<clip>
<shape android:shape="rectangle" >
<corners android:radius="5dp" />
<gradient
android:angle="270"
android:endColor="@color/gris"
android:startColor="@color/gris" />
</shape>
</clip>
</item>
</layer-list>
Run Code Online (Sandbox Code Playgroud)
这是style_progressbar_circle.xml
<selector xmlns:android="http://schemas.android.com/apk/res/android">
<item android:drawable="@drawable/red_scrubber_control_disabled_holo" android:state_enabled="false"/>
<item android:drawable="@drawable/red_scrubber_control_pressed_holo" android:state_pressed="true"/>
<item android:drawable="@drawable/red_scrubber_control_focused_holo" android:state_selected="true"/>
<item …Run Code Online (Sandbox Code Playgroud) 我有这个SeekBar:
<SeekBar
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="26dp"
android:id="@+id/seekbar"
android:visibility="gone"
android:maxHeight="3dp"/>
Run Code Online (Sandbox Code Playgroud)
我试图使用maxHeight更改此SeekBar厚度.但没有改变.它看起来像这样:
所以我的问题是有可能以某种方式改变SeekBar厚度吗?如果有,怎么样?
我有自定义绘图的SeekBar.Progress元素不是从左侧精确渲染,而是向右移动.我怎么能避免这个?
<SeekBar
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_below="@android:id/summary"
android:background="@null"
android:progressDrawable="@drawable/seekbar"
android:thumb="@drawable/seekbar_thumb"/>
Run Code Online (Sandbox Code Playgroud)
seekbar.xml
<?xml version="1.0" encoding="utf-8"?>
<layer-list xmlns:android="http://schemas.android.com/apk/res/android" >
<item
android:id="@android:id/background"
android:drawable="@drawable/seekbar_background"/>
<item android:id="@android:id/progress">
<clip android:drawable="@drawable/seekbar_progress" />
</item>
</layer-list>
Run Code Online (Sandbox Code Playgroud)
seekbar_background.xml
<?xml version="1.0" encoding="utf-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android" android:shape="line">
<stroke android:width="2dp" android:color="@color/colorNeutral" />
</shape>
Run Code Online (Sandbox Code Playgroud)
seekbar_progress.xml
<?xml version="1.0" encoding="utf-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android" android:shape="line">
<stroke
android:width="4dp"
android:color="@color/colorAccentDark" />
</shape>
Run Code Online (Sandbox Code Playgroud)
编辑:
如评论中所述,如果两个宽度相同,问题就会消失.但我需要通过drawable使它有两种不同的宽度才有可能吗?也许不同的形状不仅仅是线条?
android android-layout android-seekbar android-custom-drawable
我一直在努力做出一个习惯SeekBar.它应该有圆角.即使进步也SeekBar应该在两边都有圆角.我不需要拇指.像这样的东西.
为此,我创建了一个layer-list名为custom_seekbar.xml的xml文件,如下所示:
<?xml version="1.0" encoding="utf-8"?>
<layer-list xmlns:android="http://schemas.android.com/apk/res/android">
<item android:id="@android:id/background">
<shape android:shape="rectangle">
<corners android:radius="20dp" />
<solid android:color="#F0E9DC" />
</shape>
</item>
<item android:id="@android:id/secondaryProgress">
<clip>
<shape android:shape="rectangle">
<corners android:radius="20dp" />
<solid android:color="#F0E9DC" />
</shape>
</clip>
</item>
<item android:id="@android:id/progress">
<clip>
<shape android:shape="rectangle">
<corners android:radius="20dp" />
<solid android:color="#E38F71" />
</shape>
</clip>
</item>
</layer-list>
Run Code Online (Sandbox Code Playgroud)
为了处理移动的圆角,我想到使用一个高度等于的圆形拇指SeekBar.这是thumb.xml:
<?xml version="1.0" encoding="utf-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android"
android:shape="rectangle">
<size android:height="16dp"
android:width="16dp"/>
<corners android:radius="20dp"/>
<solid android:color="#E38F71"/>
</shape>
Run Code Online (Sandbox Code Playgroud)
我SeekBar在我的活动中展示了这样的内容:
<SeekBar
android:layout_width="250dp" …Run Code Online (Sandbox Code Playgroud) 昨天我在Android上寻找滑块,发现这个网站有谷歌搜索:https://material.io/guidelines/components/sliders.html#sliders-discrete-slider
我知道我可以SeekBar在Android中使用一个来实现滑块.但是,Google似乎有非常好的离散滑块示例,但我找不到任何代码示例.
我已经实现了一个SeekBar看起来像这样的法线:
我怎么能让它看起来像这样?
(差异:当我移动滑块时,没有显示当前值的大幅下降)
我想我可能只是错过了这些设计指南的代码文档.有谁知道在哪里找到它?或者是设计上的差异,因为我在手机上安装了Android 5.0.2?
android android-seekbar material-components material-components-android android-slider
我正在寻找一个库或开源项目,提供用于修剪视频的UI,如屏幕截图所示.包含
只是UI而不是修剪本身.
如果没有现成的解决方案,那么我现在想要以智能的方式组合现有的UI元素来实现这个或类似的东西.
这是我最终实现的: 范围选择器/范围搜索栏,用于修剪视频,包括缩略图
android video-editing video-thumbnails android-mediaplayer android-seekbar
最近我一直在研究一个有应用程序的应用程序SeekBar.该SeekBar所以可以有时很难用它(你必须在你的手势非常精确的)是相当薄.有没有办法增加可触摸区域SeekBar?因此,我希望用户能够触摸上方或下方SeekBar移动拇指.我很感激您提供的任何帮助!