【问题标题】:Android Layout Parent Right Visiblitiy display wrongAndroid Layout Parent Right Visiblitiy 显示错误
【发布时间】:2012-12-04 04:57:49
【问题描述】:

这是我的代码:

<ProgressBar
    android:id="@+id/progressBar_main"
    style="?android:attr/progressBarStyleLarge"
    android:layout_width="30dip"
    android:layout_height="30dip"
    android:layout_marginRight="8dip"
    android:layout_marginTop="8dip"
    android:layout_alignParentRight="true"
    android:visibility="gone"/>

<ImageView
    android:id="@+id/iv_broadcast"
    android:layout_width="45dip"
    android:layout_height="45dip"
    android:layout_marginRight="3dip"
    android:layout_marginTop="1dip"
    android:layout_toLeftOf="@+id/progressBar_main"
    android:scaleType="fitXY"/>

正确的图像是image1和image2,实际输出的是image1和image3。
应用程序加载数据时,加载栏将设置为VISIBLE,图像正确显示为image1。加载过程完成后,加载栏将设置为GONE,它应该显示image2,但是显示为image3,这是错误的。
我怎样才能设置纠正一个(image1 + image2),而不是(image1 + image 3)。我不知道为什么笑脸会向左走。谢谢

【问题讨论】:

  • 因为 android:layout_toLeftOf="@+id/progressBar_main" 不见了所以..

标签: android android-layout


【解决方案1】:

将 android:layout_alignParentRight="true" 赋予进度条和图像视图。

【讨论】:

    【解决方案2】:

    使用这个 imageview 代码

    <ImageView
         android:id="@+id/iv_broadcast"
         android:layout_width="45dip"
         android:layout_height="45dip"
         android:layout_alignParentRight="true"
         android:layout_marginRight="3dip"
         android:layout_marginTop="1dip"
         android:layout_toLeftOf="@+id/progressBar_main"
         android:scaleType="fitXY" />
    

    【讨论】:

    • 以线性布局(水平方向)添加 imageview 和 progressBar,因此当您设置 progressBar 的可见性消失时,imageview 自动向右移动
    猜你喜欢
    • 1970-01-01
    • 2012-11-06
    • 1970-01-01
    • 1970-01-01
    • 2019-04-09
    • 1970-01-01
    • 1970-01-01
    • 2020-11-02
    • 2018-03-08
    相关资源
    最近更新 更多