【问题标题】:ProgressBar height=match_parent进度条高度=match_parent
【发布时间】:2015-11-19 19:08:27
【问题描述】:

我有一个带单选按钮和进度条的 RelativeLayout。单选按钮应定义相对布局的高度,因此 ProgressBar 应与单选按钮具有相同的高度。但事实并非如此。

<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:tools="http://schemas.android.com/tools"
    android:layout_width="match_parent"
    android:layout_height="wrap_content" >

    <ProgressBar
        android:id="@+id/progressBar"
        style="?android:attr/progressBarStyleHorizontal"
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:progressDrawable="@drawable/progress" />

    <RadioButton
        android:id="@+id/radioButton"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content" />

</RelativeLayout>

【问题讨论】:

  • 我也有同样的问题。你解决了吗?

标签: android height android-progressbar


【解决方案1】:

我在尝试将进度条放置在其他视图后面时遇到了类似的问题。为两个子视图切换到 FrameLayout 和 gravity="center" 对我有用:

<?xml version="1.0" encoding="utf-8"?>
<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:tools="http://schemas.android.com/tools"
    android:layout_width="match_parent"
    android:layout_height="wrap_content">

   <ProgressBar
        style="@android:style/Widget.ProgressBar.Horizontal"
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:gravity="center"
        android:progress="50" />

   <LinearLayout
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:gravity="center">
        ...
   </LinearLayout>
</FrameLayout>

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2018-11-28
    • 1970-01-01
    • 2016-05-19
    • 1970-01-01
    • 2012-07-03
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多