通过代码设置SeekBar的最小高度和最大高度

4
有人知道如何通过代码设置 SeekBar 的最小和最大高度吗? 我想要复制以下 XML 摘录的相同行为:
<SeekBar android:minHeight="6dip"
         android:maxHeight="6dip" ... />
1个回答

5

我不知道是否有相关代码。我通过创建一个具有最大高度和其他属性的xml文件,并在其定义中膨胀seekBar来实现此目的:

XML中:

<?xml version="1.0" encoding="utf-8"?>
<SeekBar xmlns:android="http://schemas.android.com/apk/res/android"
        android:layout_width="fill_parent"
        android:progressDrawable="@drawable/custom_player_seekbar_background"
        android:paddingTop="10px" 
        android:paddingBottom="10px" 
        android:thumb="@drawable/bt_do_player" 
        android:paddingLeft="30px" 
        android:paddingRight="30px" 
        android:minHeight="6dip"
        android:maxHeight="6dip" 
        android:layout_height="wrap_content"
        android:layout_centerVertical="true"/>

在Java代码中:

volumeSeekBarPL = (SeekBar) getLayoutInflater().inflate(R.layout.custom_seek_bar, null);

网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接