【问题标题】:show progressbar without bottom button显示没有底部按钮的进度条
【发布时间】:2015-08-02 04:31:31
【问题描述】:

我想创建一个具有以下功能的布局: 我有一个LinearLayoutTextViewProgressbar,用于在活动应该执行网络任务时显示进度UI。我的意思是这种布局有时是可见的,有时是消失的。

我想要ScrollView 中的布局和下方页面中的button 布局下方。 我写下面的代码。并且按钮和滚动视图显示良好但是当我将LinearLayout 设置为progressBar 可见时,布局显示底部按钮。我不想在显示进度条时显示任何视图。我怎样才能更正下面的代码来解决这个问题。感谢您的建议:)

<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:card_view="http://schemas.android.com/apk/res-atuo"
    xmlns:app="http://schemas.android.com/apk/res/com.kit.itil.sdcartable"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:background="@android:color/white" >

    <LinearLayout
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:layout_above="@+id/TaskDetailActivity_btn_report"
        android:orientation="vertical" >

        <RelativeLayout
            android:id="@+id/RelativeLayoutPb_TaskDetailActivity"
            android:layout_width="match_parent"
            android:layout_height="match_parent"

            android:visibility="gone" >

            <com.kit.helper.CustomTextView
                android:id="@+id/progressText_TaskDetailActivity"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:layout_alignParentTop="true"
                android:layout_centerHorizontal="true"
                android:layout_marginTop="20dip"
                android:gravity="center"
                android:textColor="@color/gray_text"
                android:textSize="20sp"
                android:textStyle="bold" />

            <ProgressBar
                android:id="@+id/progressBar_TaskDetailActivity"
                style="?android:attr/progressBarStyleHorizontal"
                android:layout_width="70dip"
                android:layout_height="70dip"
                android:layout_centerInParent="true"
                android:indeterminate="true"
                android:indeterminateBehavior="cycle"
                android:indeterminateDrawable="@drawable/circular_progress" />
        </RelativeLayout>

        <ScrollView
            android:layout_width="match_parent"
            android:layout_height="wrap_content" >

            <LinearLayout
                android:layout_width="match_parent"
                android:layout_height="match_parent"
                android:orientation="vertical" >'

        //...some layout is here...
            </LinearLayout>
        </ScrollView>
    </LinearLayout>

    <LinearLayout
        android:id="@id/TaskDetailActivity_btn_report"
        android:layout_width="match_parent"
        android:layout_height="55dip"
        android:layout_alignParentBottom="true"
        android:background="@color/blue"
        android:gravity="center"
        android:orientation="vertical" >

        <com.kit.helper.CustomTextView
            android:id="@+id/TaskDetailActivity_TextView_report"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_gravity="center"
            android:gravity="right"
            android:text="@string/TaskDetailActivity_TextView_reportBtn"
            android:textColor="@android:color/white"
            android:textSize="20sp"
            android:textStyle="bold" />
    </LinearLayout>

</RelativeLayout>

【问题讨论】:

    标签: android user-interface android-layout progress-bar scrollview


    【解决方案1】:

    在执行网络任务时,应该使用 AsyncTask,这样它就不会在主 UI 线程上启动 如果正确使用 AsyncTask,您的问题将得到解决。

    请参考

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2019-10-16
      • 2012-04-07
      • 2016-08-24
      • 2021-02-07
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多