在xml中更改Seekbar的长度

Cod*_*ody 2 xml android android-seekbar

由于某种原因,我的搜索栏很小。我希望我的搜索栏的长度至少占据其父视图长度的一半。以下是我的xml文件:

   <?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="match_parent"
    android:layout_height="match_parent">
    <SeekBar
        android:rotation="270"
        android:id="@+id/volumeBar"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_margin="10px"
        android:layout_gravity="center" />
</LinearLayout>
Run Code Online (Sandbox Code Playgroud)

将layout_height更改为设置值(例如70dp)似乎无法解决问题。如何通过xml处理此搜索栏的长度?

Dan*_*ent 5

即使将其旋转为垂直,宽度仍然是您修改SeekBar多长时间的方式。

例如,使用以下xml:

<SeekBar
    android:rotation="270"
    android:id="@+id/volumeBar"
    android:layout_width="140dp"
    android:layout_height="wrap_content"
    android:layout_margin="10px"
    android:layout_gravity="center" />
Run Code Online (Sandbox Code Playgroud)

结果如下:

在此处输入图片说明

并与此XML:

<SeekBar
    android:rotation="270"
    android:id="@+id/volumeBar"
    android:layout_width="340dp"
    android:layout_height="wrap_content"
    android:layout_margin="10px"
    android:layout_gravity="center" />
Run Code Online (Sandbox Code Playgroud)

结果如下:

在此处输入图片说明