Warning: file_get_contents(/data/phpspider/zhask/data//catemap/0/xml/13.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Android 进度条的大小不变_Android_Xml_Progress Bar - Fatal编程技术网

Android 进度条的大小不变

Android 进度条的大小不变,android,xml,progress-bar,Android,Xml,Progress Bar,我想将ProgressBar放置在我的线性布局中: <style name="MyProgressBar" parent="@style/Widget.AppCompat.ProgressBar.Horizontal"> <item name="android:progressBackgroundTint">#69f0ae</item> <item name="android:progressTint"&g

我想将ProgressBar放置在我的线性布局中:

<style name="MyProgressBar" parent="@style/Widget.AppCompat.ProgressBar.Horizontal">
            <item name="android:progressBackgroundTint">#69f0ae</item>
            <item name="android:progressTint">#b71c1c</item>
            <item name="android:layout_width">match_parent</item>
            <item name="android:layout_height">@dimen/dp_2</item>
        </style>
但这行代码不能正常工作:

<item name="android:layout_width">match_parent</item>
大小不变

但如果我这样写smth,我的尺寸就会改变:

<item name="android:minWidth">200dp</item>

尝试创建一个样式,然后应用它。布局中的进度条应该是这样的

我认为你不需要在样式中设置布局宽度和高度

 <ProgressBar
        android:id="@+id/progressBar"
        style="?android:attr/progressBarStyleHorizontal" , <- Replace with custom style here.
        android:layout_width="match_parent"
        android:layout_height="@dimen/progressBarHeight"
        android:indeterminate="true" />

我认为match_parent仅在定义了父视图的布局上下文中起作用。在样式中使用相对于大小的属性时,需要一个数值。我只是评论一下,因为我找不到支持我假设的文档。你应该创建dimens文件。你可以在dimens文件中声明match\u parent,然后以样式调用这里。很高兴这有帮助。