【问题标题】:Android - display progress bar on top left cornerAndroid - 在左上角显示进度条
【发布时间】:2011-12-08 21:15:00
【问题描述】:

我目前正在尝试在屏幕的左上角放置一个进度条。但是,我不太确定哪种方法是最好的方法。我应该以编程方式创建进度条而不是在 xml 中创建它吗?或者我应该改变我的布局?谢谢。下面是 XML。

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"
    android:background="@drawable/background"
    android:focusableInTouchMode="true"
    android:orientation="vertical" >

    <ImageView
        android:id="@+id/imageView1"
        android:layout_width="fill_parent"
        android:layout_height="53dp"
        android:layout_marginBottom="5dp"
        android:src="@raw/topbar" />

    <TextView
        android:id="@+id/search_nameOfFeed"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:gravity="center_vertical|center_horizontal"
        android:text="Event Name"
        android:textColor="@color/black"
        android:textSize="18sp" >
    </TextView>

    <ListView
        android:id="@+id/searchfeed_view"
        android:layout_width="fill_parent"
        android:layout_height="fill_parent"
        android:layout_weight="0.83"
        android:dividerHeight="10.0sp"
        android:fadingEdge="none"
        android:stackFromBottom="false"
        android:transcriptMode="normal" >
    </ListView>

</LinearLayout>

【问题讨论】:

    标签: android layout view progress-bar


    【解决方案1】:

    当您想要在特定区域放置视图时,布局的最佳选择是FrameLayoutRelativeLayout

    RelativeLayout 将允许您将每个视图相对于彼此放置。 FrameLayout 允许您在 z-index 定位中堆叠视图。

    两者都玩,你可能会想出你想要的结果。

    【讨论】:

      【解决方案2】:

      在 android 中设计布局的最佳方式是在 XML 中创建它们,因此您应该在 XML 中进行。您可以通过在您的ImageView 之前添加您的ProgressBar 来实现您想要的

      【讨论】:

        【解决方案3】:

        我怀疑这正是您正在寻找的内容,但您可能希望实现非侵入式进度条的另一种方法是将其放在活动的标题栏中。查看this 了解如何执行此操作的示例。

        【讨论】:

          【解决方案4】:

          您可以通过任何一种方式创建它(在 XML 中或以编程方式)。如果您通过程序创建它,请将重力设置为顶部,如果您在 XML 中创建,请使用相对布局而不是线性布局并使用 android:layout_gravity="top|left"。如果要显示在中心follow the link

          【讨论】:

            猜你喜欢
            • 1970-01-01
            • 2019-11-01
            • 1970-01-01
            • 1970-01-01
            • 1970-01-01
            • 1970-01-01
            • 1970-01-01
            • 1970-01-01
            相关资源
            最近更新 更多