如何在屏幕的中心设置机器人进度条 [英] how to set android progress bar in center of the screen

查看:308
本文介绍了如何在屏幕的中心设置机器人进度条的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我试图显示在屏幕中心的进度条,但它并不在中心显示出来。下面是我的布局。我究竟做错了什么?基本上,这是一个布局显示图像和Android库部件之上。当用户点击缩略图,我加载从网上的形象,我想显示进度对话框,同时图像加载。

 < LinearLayout中的xmlns:机器人=htt​​p://schemas.android.com/apk/res/android
    的xmlns:广告=htt​​p://schemas.android.com/apk/lib/com.google.ads
    机器人:ID =@ + ID /容器机器人:layout_width =FILL_PARENT
    机器人:layout_height =FILL_PARENT机器人:方向=垂直>

    <画廊机器人:ID =@ + ID /画廊机器人:layout_width =FILL_PARENT
        机器人:layout_height =WRAP_CONTENT安卓重力=顶/>

    < ImageView的机器人:ID =@ + ID / actualimage机器人:scaleType =fitCenter
        机器人:layout_width =FILL_PARENT机器人:layout_height =WRAP_CONTENT
        机器人:能见度=水涨船高的Andr​​oid版本:layout_gravity =center_vertical | center_horizo​​ntal |中心
        机器人:adjustViewBounds =真/>

    <进度机器人:ID =@ +安卓ID / progress_small1
        机器人:layout_height =WRAP_CONTENT机器人:layout_width =WRAP_CONTENT
        机器人:能见度=看得见的机器人:layout_gravity =center_vertical | center_horizo​​ntal
        机器人:重力=center_vertical | center_horizo​​ntal/>

< / LinearLayout中>
 

解决方案

使用的LinearLayout 将垂直堆叠的意见。现在,你的的ImageView 进度正在为之奋斗的中心位置。对于这种情况,我肯定会推荐一个 RelativeLayout的

使用 RelativeLayout的,使用机器人:layout_centerInParent =真正的

I am trying to show the progress bar in the center of the screen, but it doesn't show up in the center. Below is my layout. What am i doing wrong here? Basically this is a layout to show image and android gallery widget on top. When the user clicks on the thumbnails, I am loading an image from the web and I want to show the progress dialog while the image is loading.

<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:ads="http://schemas.android.com/apk/lib/com.google.ads"
    android:id="@+id/container" android:layout_width="fill_parent"
    android:layout_height="fill_parent" android:orientation="vertical">

    <Gallery android:id="@+id/gallery" android:layout_width="fill_parent"
        android:layout_height="wrap_content" android:gravity="top" />

    <ImageView android:id="@+id/actualimage" android:scaleType="fitCenter"
        android:layout_width="fill_parent" android:layout_height="wrap_content"
        android:visibility="gone" android:layout_gravity="center_vertical|center_horizontal|center"
        android:adjustViewBounds="true" />

    <ProgressBar android:id="@+android:id/progress_small1"
        android:layout_height="wrap_content" android:layout_width="wrap_content"
        android:visibility="visible" android:layout_gravity="center_vertical|center_horizontal"
        android:gravity="center_vertical|center_horizontal" />

</LinearLayout>

解决方案

Using a LinearLayout will stack your views vertically. Right now, your ImageView and ProgressBar are fighting for the centered position. For this type of situation, I would definitely recommend a RelativeLayout.

With RelativeLayout, you use android:layout_centerInParent="true".

这篇关于如何在屏幕的中心设置机器人进度条的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆